-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
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?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers