Okay so I want one collection to have a field with an array of objectIds that point to another collection. The objectids are the _id field on this other collection.
The problem is it doesn’t work.
this is the relationship.json file on the one in the one-to-many relationship
{
"businesses": {
"ref": "#/relationship/occasionally-business-db/Business/Businesses",
"source_key": "businesses",
"foreign_key": "_id",
"is_list": true
}
}
And then here is the schema on that collection:
{
"properties": {
"_id": {
"bsonType": "objectId"
},
"userId": {
"bsonType": "objectId"
},
"businesses": {
"bsonType": "array",
"items": {
"bsonType": "objectId"
}
},
"createdAt": {
"bsonType": "date"
},
"updatedAt": {
"bsonType": "date"
}
},
"title": "AdminAccess"
}
Interestingly, if I use a string field on the business collection, which is the many in the one-to-many relationship, it does work. Seems like it should work in this case. What am I missing?
And when I say it doesn’t work, I mean it doesn’t work for graphql.
I am trying to query like this:
query {
adminAccess {
_id
createdAt
updatedAt
userId
businesses {
name
}
}
}
but businesses returns an empty array even though it shouldn’t. Has anyone had this problem?
Thanks!