Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Relationship fetching & filtering #4

Open
ShishKabab opened this issue Nov 25, 2018 · 0 comments
Open

Feature: Relationship fetching & filtering #4

ShishKabab opened this issue Nov 25, 2018 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ShishKabab
Copy link
Member

Motivation: When fetching stuff from storage, we often want to fetch related objects. By doing this in one call, we do not only gain convenience, but give some backends the chance to optimize fetching, for example by generating JOINs in SQL backends.

Design considerations:

  • When fetching an object, we want control over which child and parent objects are also fetched
  • When want to be able to filter fetched relationships (give me all customers of this company with an age over 21)
  • We want to be able to filter objects by their children (give me all customers with an active e-mail)

Example:

storageManager.registry.registerCollections({
    user: {
        version: new Date(2018, 11, 11),
        fields: {
            displayName: { type: 'string' },
            age: { type: 'number' },
        },
        indices: [],
    },
    singleEmail: {
        fields: {
            address: { type: 'string' },
            isActive: { type: 'string' },
        },
        relationships: [
            { singleChildOf: 'user' }
        ]
    },
    multiEmail: {
        fields: {
            address: { type: 'string' },
            isActive: { type: 'string' },
        },
        relationships: [
            { childOf: 'user' }
        ]
    },
})

storageManager.collection('user').findObjects({}, {relationships: ['singleEmail']})
storageManager.collection('user').findObjects({}, {relationships: {'multiEmail.active': true}})
storageManager.collection('user').findObjects({'singleEmail.active': true}, {relationships: ['singleEmail']})
# Do we allow filtering objects by childOf (one-to-many) relationships?
# Do we allow filtering objects by connects (many-to-many) relationships?
@ShishKabab ShishKabab added enhancement New feature or request good first issue Good for newcomers labels Nov 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant