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?
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:
Example: