My DB has Items and Categories. Each Item will have several Categories.
I can create an object and a collection however when added my object(ITEM) I can only add one variable to the collection(Category).
I need Many to Many Relationship.
The many to many in Backand done by adding an object that has relationships to each object, you can view it all here: many-to-many
You can also review the codepen.io to see how to work with many to many and Angular.
Many to many model between users and pets looks like this:
[
{
"name": "pets",
"fields": {
"name": {
"type": "string"
},
"owners": {
"collection": "users-pets",
"via": "pet"
}
}
},
{
"name": "users-pets",
"fields": {
"pet": {
"object": "pets"
},
"owner": {
"object": "users"
}
}
},
{
"name": "users",
"fields": {
"email": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"pets": {
"collection": "users-pets",
"via": "owner"
}
}
}
]