diff --git a/classes/Classes.CollectionAccessor.html b/classes/Classes.CollectionAccessor.html index 7d670c9..1a022b2 100644 --- a/classes/Classes.CollectionAccessor.html +++ b/classes/Classes.CollectionAccessor.html @@ -1,19 +1,19 @@ -
The data structure used by NedbClients to initialise a collection when setting up a database connection.
+The data structure used by NedbClients to initialise a collection when setting up a database connection.
You, as a user of the SuperCamo package, will typically use this class when first connecting to a database - and no other times.
Abstract
Abstract
Creates an instance of a SuperCamo document compatible with a NeDB system.
Optional
newParentDatabaseName: null | stringOptional
newCollectionName: null | stringRead-only string containing the name of the database collection that this document instance comes from.
+Read-only string containing the name of the database collection that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
A key-value pair dictionary of any data that this document instance contains.
+A key-value pair dictionary of any data that this document instance contains.
It's an object, and should have an _id
property if this document instance represents data stored in a database.
Read-only string containing the name of the database that this document instance comes from.
+Read-only string containing the name of the database that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
Delete this document from the database client that it lives in.
If you're using a databaseless-document instance, this method will throw an error!
Optional
deleteReferences: booleanSimilar to deepDeleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves. If those referenced documents also reference additional documents, those documents are unaffected and may become orphaned.
Optional
deepDeleteReferences: booleanSimilar to deleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves and recursively delete any documents that they also reference.
Number of documents deleted. You'd want this to be just 1. Other functions may use this number to create a greater tally (eg. a database client's findAndDeleteMany
method).
This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
+This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
Object containing data from the document instance.
Static
createStatic
createCreate an instance of the document's type. This does not write any data to a database.
Object containing keys of data that the document requires per its schema.
The name of the database/client that is managing this data.
The name of the collection that is using this document as a model for its data.
Optional
validateOnCreate: boolean = trueBoolean flag for whether or not a document instance created with this method should be validated ASAP. Default is true.
The folder path for where the database and its collections will be stored.
An array of collections, where each item in this array is an object containing the name of the collection and the model or document that the collection will use.
A list of meta-objects defining categories of documents in the database.
A collection is an object containing a collection name, document type, plus other properties to help access that data. This means that multiple collections could use the same document type while still keeping database records in separate collections in the database.
The set of document types used in this database.
+The set of document types used in this database.
This is calculated based on the collections that the database is configured to use, since multiple collections could use the same document type.
The set of embedded-document types used in this database.
+The set of embedded-document types used in this database.
This is calculated based on the collections that the database is configured to use, since multiple collections could use the same embedded-document type.
The name of the database.
+The name of the database.
The database's folder path, where it stores all collections.
+The database's folder path, where it stores all collections.
Query a collection and receive a number representing the count of documents matching that query.
The name of the collection that you wish search through.
The NeDB query used to find the specific document within the collection.
Integer number of documents within the specified collection that match the query.
Add a new collection to an existing database.
+Add a new collection to an existing database.
Configure an enforced constraint on a collection.
See the @seald/nedb documentation for more info about NeDB indexes.
A string of the collection name to target within the database.
An object per the @seald/nedb documentation to configure the index that is to be created.
Promise.
Create multiple document instances from a provided array of object data, insert each document instance into the database, and return the array of document instances.
+Create multiple document instances from a provided array of object data, insert each document instance into the database, and return the array of document instances.
Create a document instance from a provided object of data, insert the new document instance into the database, and return the new document instance.
+Create a document instance from a provided object of data, insert the new document instance into the database, and return the new document instance.
Delete collections by model. Can delete multiple collections that use the same model.
You can also specify whether or not the data within the collection should be deleted, just as a sanity-check. This is enabled by default.
The model to search for.
Optional
deleteData: boolean = trueWhether or not data within the collection should be deleted. Defaults to true.
The number of collections with a matching name that were deleted.
Delete collections by name. Can delete multiple collections that use the same name.
You can also specify whether or not the data within the collection should be deleted, just as a sanity-check. This is enabled by default.
The name of the collections to search for.
Optional
deleteData: boolean = trueWhether or not data within the collection should be deleted. Defaults to true.
The number of collections with a matching name that were deleted.
Find and delete multiple documents from a specified collection.
The name of the collection that you wish to search through and modify.
The NeDB query used to find the specific documents within the collection.
Options to pass to the query system in NeDB. For this particular method, multi
is always set to true
.
Number of removed documents.
Find and delete one document from a specified collection.
The name of the collection that you wish to search through and modify.
The NeDB query used to find the specific document within the collection.
Options to pass to the query system in NeDB. For this particular method, multi
is always set to false
.
Number of removed documents.
Search a database for one or more matched documents and modify them, returning the modified documents as an array of document instances.
+Search a database for one or more matched documents and modify them, returning the modified documents as an array of document instances.
If no documents match the given query, this function will return an empty array.
The name of the database collection to query.
The query to run to find the relevant document.
The data to apply to the found document.
Optional
options: updateManyOptionsOptional. The options that can be used in this operation.
Search a database for one or more matched documents and modify them, returning the modified documents as an array of plain objects.
If no documents match the given query, this function will return an empty array.
The name of the database collection to query.
The query to run to find the relevant document.
The data to apply to the found document.
Optional
options: updateManyOptionsOptional. The options that can be used in this operation.
Search a database for a singular matched document and modify it, returning the modified document as a document instance.
+Search a database for a singular matched document and modify it, returning the modified document as a document instance.
The name of the database collection to query.
The query to run to find the relevant document.
The data to apply to the found document.
Optional
options: updateOptionsOptional. The options that can be used in this operation.
Search a database for a singular matched document and modify it, returning the modified document as a plain object.
The name of the database collection to query.
The query to run to find the relevant document.
The data to apply to the found document.
Optional
options: updateOptionsOptional. The options that can be used in this operation.
Query a collection and return an array of document instances matching that query.
+Query a collection and return an array of document instances matching that query.
This method is NOT compatible with NeDB projections.
Even if nothing matches the given query, an array is returned.
The name of the collection that you wish to search through.
@@ -122,7 +122,7 @@Optional
options: findManyDocumentsOptionsOptional. Configuration for this database operation.
An instance of the collection's model.
Query a collection and return an array of objects matching that query, where each object is a document's data.
This method is compatible with NeDB projections, allowing you to trim the returned data. Read more in the NeDB documentation.
Even if nothing matches the given query, an array is returned.
The name of the collection that you wish to search through.
@@ -130,36 +130,36 @@Optional
options: findManyObjectsOptionsOptional. Configuration for this database operation.
An instance of the collection's model.
Query a collection and receive the first document matching that query, returned as a document instance.
+Query a collection and receive the first document matching that query, returned as a document instance.
This method is NOT compatible with NeDB projections, and thus returns an instance of the document used by the specified collection.
The name of the collection that you wish to search through.
The NeDB query used to find the specific document within the collection. Read more about NeDB queries here: https://github.com/seald/nedb?tab=readme-ov-file#finding-documents
An instance of the collection's model.
Query a collection and receive the first document matching that query, returned as a plain object.
This method is compatible with NeDB projections, allowing you to trim the returned data. Read more in the NeDB documentation.
The name of the collection that you wish to search through.
The NeDB query used to find the specific document within the collection. Read more about NeDB queries here: https://github.com/seald/nedb?tab=readme-ov-file#finding-documents
Optional
options: findOneObjectOptionsOptional. Configuration for this database operation.
An instance of the collection's model.
Retrieve the collection meta object stored on the NeDB client instance matching a given collection name.
+Retrieve the collection meta object stored on the NeDB client instance matching a given collection name.
A string of the collection name to target within the database.
An object containing helper properties to perform collection-related operations.
Insert an array of objects of data into the database, following a document schema, and return the saved array of objects of data.
The name of the collection to insert the data into.
The data to be inserted.
The data saved in the database, as an object.
Insert an object of data into the database, following a document schema, and return the saved object of data.
The name of the collection to insert the data into.
The data to be inserted.
The data saved in the database, as an object.
Remove a collection's index from an array of given field names.
A string of the collection name to target within the database.
An array containing one or more fields on the collection that you'd like to remove the index from.
Promise.
Read-only string containing the name of the database collection that this document instance comes from.
+Read-only string containing the name of the database collection that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
A key-value pair dictionary of any data that this document instance contains.
+A key-value pair dictionary of any data that this document instance contains.
It's an object, and should have an _id
property if this document instance represents data stored in a database.
Read-only string containing the name of the database that this document instance comes from.
+Read-only string containing the name of the database that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
Delete this document from the database client that it lives in.
If you're using a databaseless-document instance, this method will throw an error!
Optional
deleteReferences: booleanSimilar to deepDeleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves. If those referenced documents also reference additional documents, those documents are unaffected and may become orphaned.
Optional
deepDeleteReferences: booleanSimilar to deleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves and recursively delete any documents that they also reference.
Number of documents deleted. You'd want this to be just 1. Other functions may use this number to create a greater tally (eg. a database client's findAndDeleteMany
method).
This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
+This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
Object containing data from the document instance.
Static
createStatic
createCreate an instance of the document's type. This does not write any data to a database.
Object containing keys of data that the document requires per its schema.
The name of the database/client that is managing this data.
The name of the collection that is using this document as a model for its data.
Optional
validateOnCreate: boolean = trueBoolean flag for whether or not a document instance created with this method should be validated ASAP. Default is true.
Read-only string containing the name of the database collection that this document instance comes from.
+Read-only string containing the name of the database collection that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
A key-value pair dictionary of any data that this document instance contains.
+A key-value pair dictionary of any data that this document instance contains.
It's an object, and should have an _id
property if this document instance represents data stored in a database.
Read-only string containing the name of the database that this document instance comes from.
+Read-only string containing the name of the database that this document instance comes from.
If this is null, assume that this document instance does not represent any data stored in a database.
Delete this document from the database client that it lives in.
If you're using a databaseless-document instance, this method will throw an error!
Optional
deleteReferences: booleanSimilar to deepDeleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves. If those referenced documents also reference additional documents, those documents are unaffected and may become orphaned.
Optional
deepDeleteReferences: booleanSimilar to deleteReferences
, but you can pick one or the other. If true, all referenced documents will also delete themselves and recursively delete any documents that they also reference.
Number of documents deleted. You'd want this to be just 1. Other functions may use this number to create a greater tally (eg. a database client's findAndDeleteMany
method).
This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
+This document instance's data, and only the data, organized onto an object. This also retrieves data from referenced documents and stores their data as a nested object within this document, too.
Object containing data from the document instance.
Static
createStatic
createCreate an instance of the document's type. This does not write any data to a database.
Object containing keys of data that the document requires per its schema.
The name of the database/client that is managing this data.
The name of the collection that is using this document as a model for its data.
Optional
validateOnCreate: boolean = trueBoolean flag for whether or not a document instance created with this method should be validated ASAP. Default is true.
let pokemonDatabase = SuperCamo.clientConnect(
"Pokemon Database",
"./Storage",
[
new CollectionListEntry("Users", User),
new CollectionListEntry("CapturedPokemon", Pokemon),
new CollectionListEntry("WildPokemon", Pokemon)
]
);
-Static
clientGet a list of databases connected.
Static
clientCreate a database client instance, connecting to it and returning its instance.
+Static
clientCreate a database client instance, connecting to it and returning its instance.
A unique name for the database.
Optional
databaseDirectory: string = ""The folder path for where the database and its collections will be stored.
Optional
collectionsList: CollectionsListEntry[] = []An array of collections, where each item in this array is an object containing the name of the collection and the model or document that the collection will use.
Optional
clientType: typeof NedbClient = NedbClientA custom type of database client, though you can leave this blank to use the default SuperCamo database client.
The newly-created database client instance.
Static
clientStatic
clientStatic
clientStatic
clientStatic
clientCreate an accessor for a database that is connected in the app.
+Static
clientCreate an accessor for a database that is connected in the app.
The name of the database that you wish to connect to.
A NedbClient instance.
Optional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionOptional
constructorOpt: FunctionThis is a NoSQL "ODM" built for usage with NeDB. You can define schemas for the data that you want to store in a NeDB database, and the objects that get used within NeDB will obey the rules and functionalities defined by your schemas.
+This is a NoSQL "ODM" built for usage with NeDB. You can define schemas for the data that you want to store in a NeDB database, and the objects that get used within NeDB will obey the rules and functionalities defined by your schemas.
It's like how MongooseJS is for MongoDB - SuperCamo is for NeDB.
Install this package as a production dependency using this command:
npm install @bigfootds/supercamo
@@ -42,4 +42,4 @@
const {
// Used for document definitions
NedbEmbeddedDocument,
// Used for document definitions
NedbDocument,
// Used for most package functionality, especially database interactions
SuperCamo,
// Used for database client initial connections
CollectionListEntry,
// Handy for JSDoc typing or other intellisense, in this code example
NedbClient
} = require("@bigfootds/supercamo");
// Realistically, you'll wanna use `path` to figure out a good, relative, cross-platform path for your database storage.
const path = require("node:path");
class Bio extends NedbEmbeddedDocument {
constructor(newData, newParentDatabaseName, newCollectionName){
super(newData, newParentDatabaseName, newCollectionName);
this.rules = {
tagline: {
type: String,
required: true,
unique: false
},
blurb: {
type: String,
required: true,
unique: false
}
}
}
}
class User extends NedbDocument {
constructor(newData, newParentDatabaseName, newCollectionName){
super(newData, newParentDatabaseName, newCollectionName);
this.rules = {
email: {
type: String,
required: true,
unique: true
},
bio: {
type: Bio,
required: false
}
}
}
}
async function databaselessExample(){
let newUserInstance = new User({
email: "contact@bigfootds.com",
bio: {
blurb: "Some cool blurb goes here.",
tagline: "Some cool tagline goes here."
}
});
await newUserInstance.validate().catch(error => {
console.log("Validation failed.");
throw error;
});
console.log("Validation passed!");
console.log(newUserInstance.data);
}
async function databaseConnectedExample(){
/**
* @type {NedbClient}
*/
let newClient = SuperCamo.clientConnect(
"QuickstartDatabase",
path.join(process.cwd(), "databases", "QuickStartDatabase"),
[
new CollectionListEntry("Users", User),
]
);
let newUser = await newClient.createOne("Users", {
email: "contact@bigfootds.com",
bio: {
blurb: "Some cool blurb goes here.",
tagline: "Some cool tagline goes here."
}
});
console.log(newUser.data);
// In other files, you can retrieve that connected database client through SuperCamo too.
// So you wanna connect to a specific database once, and retrieve that connection throughout your project.
let quickstartDbRetrieved = SuperCamo.clientGet("QuickstartDatabase");
let foundUser = await quickstartDbRetrieved.findOneDocument("Users", {email: "contact@bigfootds.com"});
console.log(foundUser.data);
}
// Use one or the other to see the code in action.
// databaselessExample();
// databaseConnectedExample();
-
SuperCamo is a package built as a wrapper around NeDB. It contains several key parts that you need to understand to really make good use of this package, and you would benefit from also digging around in NeDB package documentation - but we'll point that out when it's necessary in the other documentation pages.
+SuperCamo is a package built as a wrapper around NeDB. It contains several key parts that you need to understand to really make good use of this package, and you would benefit from also digging around in NeDB package documentation - but we'll point that out when it's necessary in the other documentation pages.
This page will walk you through the key components of this package and briefly explain what they are, as well as when you need to use them.
There are a lot of moving pieces in this system. In a nutshell:
This package is all about making it easier to manage multiple NeDB database connections within a single app's lifetime. The SuperCamo singleton is how that happens.
@@ -39,4 +39,4 @@Read more about the SuperCamo database client on its tutorial page.
So, those are the four main components to SuperCamo. If that sounds interesting to you, keep digging into this documentation and start coding!
Go and get started!
-This package is all about making it easier to manage multiple NeDB database connections within a single app's lifetime. The SuperCamo singleton is how that happens.
+This package is all about making it easier to manage multiple NeDB database connections within a single app's lifetime. The SuperCamo singleton is how that happens.
Essentially, you should connect to a database via the SuperCamo singleton. The SuperCamo.clientConnect()
function returns a reference to the database client instance, and that same instance can be retrieved again in any file that uses the SuperCamo singleton too.
This means that when your app runs, you should follow this process:
const SuperCamo = require("@bigfootds/supercamo");
const databaseInstance = SuperCamo.clientGet("BasicExampleDatabase");
router.get("/all", async (request, response) => {
let availableArticles = await databaseInstance.findManyObjects("Articles", {});
response.json(availableArticles);
});
-NeDB is a NoSQL database. That means that instead of tables and rows to represent entities of data, we use collections of documents.
+NeDB is a NoSQL database. That means that instead of tables and rows to represent entities of data, we use collections of documents.
Traditionally, one NeDB datastore is one collection. SuperCamo manages that for you, so you just have to assign a document and a collection name to a database client to make that work the same way you'd expect from popular NoSQL systems like MongoDB and MongooseJS.
Declaring a document is how you can define a schema or structure for your data.
Like so:
@@ -28,4 +28,4 @@The above example queries for a user with a username that exactly matches "Bigfoot"
, and returns an instance of the User document with the data of that matching user.
Documents can refer to other documents, specify minimum and maximum values of properties, restrict property values to a set of choices, and more. You can read more about Document usage and functionalities in other pages - this is just a brief intro for now! 😉
-Subdocuments or embedded documents are a way of structuring complex data nested within documents. While a document can have objects as its properties/fields, it's typically more straightforward to create embedded documents to represent objects instead.
+Subdocuments or embedded documents are a way of structuring complex data nested within documents. While a document can have objects as its properties/fields, it's typically more straightforward to create embedded documents to represent objects instead.
Embedded documents have their own validation step, so you can configure validation rules in a declared embedded document and they will run when the document that contains the embedded document runs. Might sound hard to keep track of, but basically: embedded documents are identical to regular documents, except you cannot use embedded documents as standalone documents. They can only exist as properties within documents.
For example:
const {NedbEmbeddedDocument} = require('@bigfootds/supercamo');
const ISO6391 = require('iso-639-1');
let allowedLanguageCodes = ISO6391.getAllCodes();
class LocalizedContent extends NedbEmbeddedDocument {
constructor(data, databaseName, collectionName){
super(data, databaseName, collectionName);
/**
* A two-letter language code that matches the language of this subdocument's name and content.
* Examples: "EN", "FR", "DE"
* Refer to the ISO-639-1 standard online for the full list of usable codes.
*/
this.language = {
type: String,
choices: allowedLanguageCodes,
unique: false,
required: true
}
/**
* Content written in the language assigned to this.language.
*/
this.content = {
type: String,
required: true,
unique: false
}
}
}
module.exports = { LocalizedContent };
@@ -14,4 +14,4 @@
Embedded documents are not impacted by any document population settings - a query to a document will return all of its embedded document data.
This is because embedded documents are stored as objects within the containing document, and only convert back into Embedded Document instances during validation steps.
-
The database client is the main way that you should be interacting with the database in this package.
+The database client is the main way that you should be interacting with the database in this package.
To work with data based on the documents that you've defined, you must create an instance of a database client.
Essentially, we must tell each database client instance which documents (a.k.a models) they're allowed to use. We do this by specifying a key-value pair list of collections and their models.
const SuperCamo = require("@bigfootds/supercamo");
let exampleDb = await SuperCamo.connect(
"SomeDatabaseName",
path.join(process.cwd(), "databases", "SomeDatabaseName"),
[
{name: "Users", model: User},
{name: "Admins", model: User},
{name: "Profiles", model: Profile},
{name: "Config", model: Settings}
]
);
@@ -13,4 +13,4 @@
let newUser = await exampleDb.insertOne("Users", {name:"Alex", email:"test@email.com"})
console.log(newUser.toString());
let newUsers = await anotherDb.insertMany("Users", [
{name:"Not Alex", email:"test@email.com"},
{name:"Definitely Not Alex", email:"test2@email.com"},
{name:"Could be Alex, but probably not", email:"test3@email.com"},
]);
console.log(newUsers.toString());
-
This section introduces the fundamental concepts that this package relies on. There are only a few main components. In general, when using this package, you will want to:
+This section introduces the fundamental concepts that this package relies on. There are only a few main components. In general, when using this package, you will want to:
There are some cool things that you can do with this package!
+There are some cool things that you can do with this package!
TypeScript can pick up more information from this package than regular JavaScript can. This isn't a huge deal, but it does help in some situations, such as when you're declaring the rules within a document.
When your cursor is within a rule object, you can enter a keyboard shortcut to show all compatible values based on your cursor's position. In TypeScript, this will show all possible constraints that you can define in a document's rule. Like so:
class CustomClient extends NedbClient {
constructor(dbName, dbDirectoryPath, collectionsList, coolFactor){
super(dbName, dbDirectoryPath, collectionsList);
this.coolFactor = coolFactor || 10;
}
}
-Pass a string to this, and it'll automatically figure out which NodeJS util.DebugLogger to use.
+Pass a string to this, and it'll automatically figure out which NodeJS util.DebugLogger to use.
This is not a function that you should be using within your own project's code, but this is more for anyone who is contributing to SuperCamo development to use.
If you're not a contributor, you may just wanna stick to the parent "Logging" page so you can see the NODE_DEBUG
values that you can use to see this package's logger output instead.
You would use this within the SuperCamo package's code in place of console.log
statements. Refer to the example section below.
BigfootDS
-SuperCamo is a Camo-inspired object data modeller (ODM) for NeDB, built specifically for BigfootDS' needs.
+SuperCamo is a Camo-inspired object data modeller (ODM) for NeDB, built specifically for BigfootDS' needs.
This package was inspired by Scott Robinson's Camo ODM - but BigfootDS had some specific needs and an urge to try out TypeScript. We greatly appreciate what Camo is and does!
Those repositories are also used to dogfood this library - features needed for those projects will be prioritised. Check their readme files to see what is mapped out on each repository.
-The name of the collection that the data for this document instance has come from. Useful for checking if a database already has this document when a database client is using the same model in multiple collections, from the document or generic functions.
@@ -12,10 +12,10 @@Storage of the document data, used when making instances of document-based classes to create documents.
+Storage of the document data, used when making instances of document-based classes to create documents.
eg. this.username
would define the rules that the data must obey for the username
property of a document, while the actual data for username
should live in this.data.username
.
The name of the database that the data for this document instance has come from. Useful for checking if a database already has this document, from the document or generic functions.
+The name of the database that the data for this document instance has come from. Useful for checking if a database already has this document, from the document or generic functions.
However, this will be null if the document instance was created without the involvement of a database query.
No value:
let newUser = await User.create({username:"alex"});
console.log(newUser.parentDatabaseName); // null/undefined expected
@@ -26,4 +26,4 @@
Reference to the NeDB Datastore object for this collection.
Reference to the NedbDocument-inheriting class used to define the collection's data structure.
+Reference to the NedbDocument-inheriting class used to define the collection's data structure.
Name of the collection.
+Name of the collection.
Path to its ".db" NeDB file.
+Path to its ".db" NeDB file.
Optional
choicesAn array of data that should match the specified type, to restrict the possible values of this property.
Optional
collectionUsed for properties that are references to other documents. The value of this should be the name of the collection that the referenced document lives in. +
Optional
collectionUsed for properties that are references to other documents. The value of this should be the name of the collection that the referenced document lives in.
eg. collection: "Users",
would be useful for refering to documents that live in a "Users" collection of a database.
No, you cannot refer to collections that exist in separate database clients.
Optional
defaultThe default data of this property, to be used if no data is provided or if a soft-invalidation occurs.
+Optional
defaultThe default data of this property, to be used if no data is provided or if a soft-invalidation occurs.
Optional
invalidateDetermines whether not an invalid value for min, max, minLength, and maxLength properties will throw an error or just roll-over and allow the value to exist. +
Optional
invalidateDetermines whether not an invalid value for min, max, minLength, and maxLength properties will throw an error or just roll-over and allow the value to exist. Depending on the property, it may get replaced with a default or min or max value if this is set to false.
Optional
matchThe regex expression that will be run against this property's data value. If the regex doesn't match, validation fails.
+Optional
matchThe regex expression that will be run against this property's data value. If the regex doesn't match, validation fails.
Optional
maxThe highest value that this property can have for its data value. +
Optional
maxThe highest value that this property can have for its data value. For properties that are numbers.
Optional
maxThe highest length that this property can have for its data value. +
Optional
maxThe highest length that this property can have for its data value. For properties that are strings or arrays.
Optional
minThe lowest value that this property can have for its data value. +
Optional
minThe lowest value that this property can have for its data value. For properties that are numbers.
Optional
minThe shortest length that this property can have for its data value. +
Optional
minThe shortest length that this property can have for its data value. For properties that are strings or arrays.
Optional
padIf an array data value's length is too short, this is the value that will be used to pad the array until it meets the minLength
property.
Optional
padIf an array data value's length is too short, this is the value that will be used to pad the array until it meets the minLength
property.
Optional
padIf a string data value is too short, this is the value that will be used to pad the data until it meets the minLength
property.
Optional
padIf a string data value is too short, this is the value that will be used to pad the data until it meets the minLength
property.
Optional
requiredWhether or not a property defined in the document's rules
object must have a value in its data.
Optional
requiredWhether or not a property defined in the document's rules
object must have a value in its data.
A JavaScript class or type. +
A JavaScript class or type. This should be on every document key rule object, it is required. Various other constraints depend on the type!
Optional
uniqueWhether or not the data value for this property should be unique within the database. This sets up a NeDB index, so it's not immediately checked at a SuperCamo level - but NeDB immediately enforces it.
+Optional
uniqueWhether or not the data value for this property should be unique within the database. This sets up a NeDB index, so it's not immediately checked at a SuperCamo level - but NeDB immediately enforces it.
Optional
validateA custom validate function that runs alongside any other constraints. The function must receive one parameter, which the document will pass in automatically - the parameter is the document's data for this property.
+Optional
validateA custom validate function that runs alongside any other constraints. The function must receive one parameter, which the document will pass in automatically - the parameter is the document's data for this property.
Array of collections used by this NeDB client. This is essentially where you track what models and collections are used in this particular database.
Array of documents used by the collections within this NeDB client. This should be a smaller array than the collections, since multiple collections could be using the same document.
+Array of documents used by the collections within this NeDB client. This should be a smaller array than the collections, since multiple collections could be using the same document.
Array of subdocuments or embedded documents used by the documents within the collections of this NeDB client.
+Array of subdocuments or embedded documents used by the documents within the collections of this NeDB client.
Human-friendly name to identify the database when an app using SuperCamo is using multiple NeDB database connections simultaneously.
+Human-friendly name to identify the database when an app using SuperCamo is using multiple NeDB database connections simultaneously.
The absolute file path to the folder that represents this NeDB client. Its collections are individual NeDB datastore files contained within this folder.
+The absolute file path to the folder that represents this NeDB client. Its collections are individual NeDB datastore files contained within this folder.
Configuration object for methods that find many documents at once.
+Configuration object for methods that find many documents at once.
Configuration object for methods that find many documents as objects at once.
+Configuration object for methods that find many documents as objects at once.
A number to limit how many documents should be returned during a findMany operation.
A NeDB projection object. This is passed along as-is to NeDB, so please refer to their documentation about projections.
+A NeDB projection object. This is passed along as-is to NeDB, so please refer to their documentation about projections.
https://github.com/louischatriot/nedb?tab=readme-ov-file#projections
A NeDB projection object. This is passed along as-is to NeDB, so please refer to their documentation about projections.
https://github.com/louischatriot/nedb?tab=readme-ov-file#projections
Configuration object for methods that update many documents at once.
+Configuration object for methods that update many documents at once.
A number to limit how many documents should be updated during an updateMany operation.
During the requested update operation, if no document already exists that matches the query, this controls whether or not a new document should be created. +
During the requested update operation, if no document already exists that matches the query, this controls whether or not a new document should be created. If true: a new document is created. If false: no new document is created.
Configuration object for methods that update a singular document at a time.
+Configuration object for methods that update a singular document at a time.
These classes will be the most-common thing you'll interact with when using this package.
+These classes will be the most-common thing you'll interact with when using this package.
Typically, you'd be using the SuperCamo singleton class for its static methods and defining your own document models by inheriting from NedbDocument and NedbEmbeddedDocument classes.
NodeJS CommonJS import:
const {SuperCamo} = require("@bigfootds/supercamo");
SuperCamo.clientConnect(/* params go here */);
@@ -11,11 +11,11 @@ Exampleimport {SuperCamo} from "@bigfootds/supercamo";
SuperCamo.clientConnect(/* params go here */);
-Interface
The core properties of any type of document used in SuperCamo.
+Interface
The core properties of any type of document used in SuperCamo.
Configured logging system for the SuperCamo package.
+Configured logging system for the SuperCamo package.
This is not something for users of the SuperCamo package to directly use. Instead, this is something impacted by usage of the NODE_DEBUG environment variable.
For example, if you want logging from multiple packages, including SuperCamo, you may want to set NODE_DEBUG to be or include "verbose". This would enable multiple packages to log. But if you only want SuperCamo to log, and not any other packages, you may want to set NODE_DEBUG to be or include "supercamo".
@@ -13,5 +13,5 @@BigfootDS
-This is the content that you can import in your own code.
+This is the content that you can import in your own code.
The data structure used by NedbClients to manage their collections of documents.
+- Preparing search index...
- The search index is not available
SuperCamo - v1.0.0Class CollectionAccessor
The data structure used by NedbClients to manage their collections of documents.
The path and datastore are used in the actual persisting of the data by NeDB.
The name and model are used by SuperCamo to determine what document rules to apply to the collection's data.
This is not a class that you, as a user of the SuperCamo package, will typically interact with or use directly at all.
Author
BigfootDS
-Implements
Index
Constructors
Implements
Index
Constructors
Properties
Constructors
constructor
Parameters
Returns CollectionAccessor
Properties
datastore
Reference to the NeDB Datastore object for this collection.
+Constructors
constructor
Parameters
Returns CollectionAccessor
Properties
datastore
Reference to the NeDB Datastore object for this collection.
Author
BigfootDS
-model
Reference to the NedbDocument-inheriting class used to define the collection's data structure.
+model
Reference to the NedbDocument-inheriting class used to define the collection's data structure.
Author
BigfootDS
-name
Name of the collection.
+name
Name of the collection.
Author
BigfootDS
-path
Path to its ".db" NeDB file.
+path
Path to its ".db" NeDB file.
Author
BigfootDS
-Settings
On This Page
Constructors
Properties