Example of SuperCamo usage in a NodeJS terminal application.
This example uses documents and embedded documents.
Model schema summaries as follows:
// User - Document
{
"username":"String",
"biography":["LocalizedContent subdocument"],
"password":"String"
}
// LocalizedContent - Subdocument
{
"language":"String",
"content":"String"
}
// Article - Document
{
"title":["LocalizedContent subdocuments"],
"content":["LocalizedContent subdocuments"],
"authors":["User document references"]
}
The dependency of the models can be pictured like this:
graph TD
A(Article) -- has reference to many --> B(User)
A -- contains many --> C(LocalizedContent)
B -- contains many --> C
- Create documents via insertMany
- Create documents via insertOne
- Create documents that refer to other documents by ID
- Create documents that use embedded documents
- Retrieve all documents in a specific collection as objects
- Retrieve all documents in a specific collection as document instances
- Retrieve all documents in all collections as objects
- Retrieve all documents in all collections as objects, populating any referenced data
- Retrieve all documents in all collections as document instances
- Retrieve a specific document by specific query as an object
- Retrieve a specific document by specific query as an object, populating any referenced data
- Retrieve a specific document by specific query as a document instance
- Update document primitive-typed data
- Update a document's embedded document-typed data
- Delete all documents from all collections
- Delete a specific document from a specific collection