Skip to content

Simple relationships definitions in Schema #6

@celrenheit

Description

@celrenheit

It would be nice to handle some simple relationships handling between models.

I propose this configuration:

var UserSchema = new Schema({
    name: String,
    email: String,
    username: String
});


UserSchema.relationships = {
    'createdArticles': {   
        model: 'Article',
        direction: 'OUT',
        edgeLabel: 'created'
    },
    'follows': {
        model: 'User',
        direction: 'OUT',
        edgeLabel: 'follows'
    },
    'followedBy': {
        model: 'User',
        direction: 'IN',
        edgeLabel: 'follows'
    }
};

// AND/OR

UserSchema.relationships.add('createdArticles', {   
    model: 'Article',
    direction: 'OUT',
    edgeLabel: 'created'
})

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions