Subdocuments
Q3 registers a global mongoose plugin for easier subdocument management.
API reference
Example code
// Let's make John
const doc = Model.create({
name: "John",
});
// John finds a new friend
const { friends: [{ _id }] } = await doc.pushSubDocument('friends', {
name: "Jen",
});
// John's friend changes her name
await doc.updateSubDocument('friends', _id, { name: "Jennifer" });
// John no longer has any friends.
await doc.removeSubDocument('friends', _id);
Last updated