Private
cleanCreate a document based on the model.
Identical to Model(data)
The data / properties in the new document
Optional
options: { Optional
uri?: stringFind documents from the model.
// Find all documents for this model
await Model.find({});
// Find with filter
await Model.find({first_name: "Lester"});
// Find with nested filter
await Model.find({primary_contact: {first_name: "Lester"}});
// Find with array filter, currently only supports $in
await Model.find({hobbies: {$in: ['coding', 'jogging']}});
// Find with compare filter, supports $le, $lt, $ge, $gt
await Model.find({age: {$lt: 100, $gt: 20}}); // less than 100 and greater than 20
await Model.find({age: {$le: 100, $ge: 20}}); // less or equal to 100 and greater or equal to 20
// Find all documents with populates, support nested populates.
await Model.find({}, {
populates: [
'primary_contact', // Populate primary_contact
'organization.primary_contact' // Populate organization and organization.primary_contact
]
});
// Find all clients where the characteristic_14 contains 'le' and characteristic_15='lyu'
await GDBClientModel.find({
characteristicOccurrences: {
$and: [
{occurrenceOf: ":characteristic_14", dataStringValue: 'lester'},
{occurrenceOf: ":characteristic_15", dataStringValue: 'lyu'}
]
}
});
Optional
options: { Optional
ignoreOptional
populates?: anyThe found documents.
Find all documents matched to the filter and delete.
// Find all documents have primary_contact.first_name equal to 'Lester' and delete them.
const doc = await Model.findAndDelete({primary_contact: {first_name: 'Lester'}});
The filter.
Optional
options: { Optional
ignoreFind a document by ID in the model.
find for further information
// Same as
(await Model.find({_id: id}, {populates}))[0];
// Find one document with _id = 1 and populate
Model.findById(1, {populates: ['primary_contact']});
ID of the document, usually represents as _id
Optional
options: { Optional
ignoreOptional
populates?: anyFind one document by ID and delete it.
// Find one document has id 1 and delete it.
const doc = await Model.findByIdAndDelete(1);
The identifier
Optional
options: { Find one document by ID and update
// Find a document has id = 1 and update the primary_contact.first_name to 'Lester'
const doc = await Model.findByIdAndUpdate(1, {primary_contact: {first_name: 'Lester'}});
The identifier
The Update to the found document
Optional
options: { Optional
ignoreFind a document by URI in the model.
find for further information
// Same as
(await Model.find({_uri: uri}, {populates}))[0];
// Find one document with _uri = "http://example/1" and populate
Model.findByUri("http://example/1", {populates: ['primary_contact']});
ID of the document, usually represents as _id
Optional
options: { Optional
ignoreOptional
populates?: anyFind one document by URI and delete it.
// Find one document has uri "http://example.com/person/1" and delete it.
const doc = await Model.findByUriAndDelete("http://example.com/person/1");
The identifier
Optional
options: { Find one document by URI and update
// Find a document has uri = "http://example.com/person/1" and update the primary_contact.first_name to 'Lester'
const doc = await Model.findByUriAndUpdate("http://example.com/person/1", {primary_contact: {first_name: 'Lester'}});
The unique identifier
The Update to the found document
Optional
options: { Optional
ignoreFind one document in the model.
find for further information
// Same as
await (Model.find(filter, {populates}))[0];
// Find one document and populate
Model.findOne({age: 50}, {populates: ['primary_contact']});
The filter
Optional
options: { Optional
ignoreOptional
populates?: anyFind one document matched to the filter and delete.
// Find one document have primary_contact.first_name equal to 'Lester' and delete it.
// The document with smaller id will be deleted if found multiple documents.
const doc = await Model.findOneAndDelete({primary_contact: {first_name: 'Lester'}});
The filter *
Optional
options: { Find one document and update.
// Find a document has _id = 1 and update the primary_contact.first_name to 'Lester'
// The document has smaller id will be updated if it finds multiple matched documents.
const doc = await Model.findOneAndUpdate({_id: 1}, {primary_contact: {first_name: 'Lester'}});
The filter
The Update to the found document
Optional
options: { Optional
ignoreGenerate creation query.
Private
generatePrivate
Generate delete query of a document.
Optional
cnt: number = 0Private
generatePrivate
getStatic
initInternally create a GraphDBModel class
Generated using TypeDoc
Create a document based on the model. Note: The constructor does not comply OOP since it is dynamically generated. Same as
GraphDBModel.createDocument
Name
GraphDBModel
Param
The data / properties in the new document
Returns