NedbClient

new NedbClient(dbDirectoryPath, dbName, collectionsList)

Creates an instance of NedbClient.

Parameters:
NameTypeDescription
dbDirectoryPathString

A string representing a resolved path to a directory. This directory will store the database client's specific directory - so dbDirectoryPath is not the folder that contains any ".db" files in it.

dbNameString

A string used to identify a database. No checks for uniqueness will happen, that's up to you to manage. The directory that is a resolved path from dbDirectoryPath and dbName will contain many ".db" files in it.

collectionsListArray.<CollectionsList>

An array of objects containing a desired name for a collection as well as the NedbDocument-inheriting model that should be used for that collection. You must provide ALL intended models & collections for the database client in this property - don't leave anything out!

Author
  • BigfootDS
Example
let settingsDb = new NedbClient(
     somePathToFolder,
     [
         {name:"Users", model: User}, 
         {name:"Admins", model: User}, 
         {name: "Config", model: Config}
     ]
);

Members

collectionExistsInInstance

Determine whether or not a specific collection name exists in the used database client instance.

Author
  • BigfootDS

(async) count

Query a collection and receive a number representing the count of documents matching that query.

Author
  • BigfootDS

(async) createIndex

Create an index on a specified collection's field(s), as per the NeDB documentation:

https://github.com/seald/nedb?tab=readme-ov-file#indexing

Author
  • BigfootDS

driver

Gets the raw collections list from the database client instance.

Try not to use this - use the methods on the instance to do things to/with collections instead.

Author
  • BigfootDS

(async) dropDatabase

Remove all documents from all collections.

Author
  • BigfootDS

(async) dumpDatabase

Retrieves all documents from all collections, turns them all into objects, and puts them all into an array.

Author
  • BigfootDS

(async) dumpDatabaseDocuments

Retrieves all documents from all collections, turns them all into objects, and puts them all into an array.

Author
  • BigfootDS

(async) findAndDeleteMany

Find and delete multiple documents from a specified collection.

Author
  • BigfootDS

(async) findAndDeleteOne

Find and delete one document from a specified collection.

Author
  • BigfootDS

(async) findAndUpdateMany

Find and update or or more matching documents within a specified collection, as per the NeDB documentation.

https://github.com/seald/nedb?tab=readme-ov-file#updating-documents

Author
  • BigfootDS

(async) findAndUpdateOne

Find and update one matching document within a specified collection, as per the NeDB documentation.

https://github.com/seald/nedb?tab=readme-ov-file#updating-documents

Note that if multiple documents would match the given query, only the first matched document will be updated.

Author
  • BigfootDS

(async) findManyDocuments

Query a collection and receive one or more documents matching that query.

This method is NOT compatible with NeDB projections, and thus returns an array of instances of the document used by the specified collection.

Author
  • BigfootDS

(async) findManyObjects

Query a collection and receive one or more objects matching that query.

This method is compatible with NeDB projections, and thus returns an array of plain object.

Author
  • BigfootDS

(async) findOneDocument

Query a collection and receive the first document matching that query.

This method is NOT compatible with NeDB projections, and thus returns an instance of the document used by the specified collection.

Author
  • BigfootDS

(async) findOneObject

Query a collection and receive the first document (as an object) matching that query.

This method is compatible with NeDB projections, and thus returns a plain object.

Author
  • BigfootDS

getCollectionAccessor

Retrieve the collection meta object stored on the NeDB client instance matching a given collection name.

Author
  • BigfootDS

getModelsList

Retrieve a distinct list of models used in the collections of this NedbClient.

Author
  • BigfootDS

(async) insertMany

Create multiple new documents within a specified collection, as per the NeDB documentation.

https://github.com/seald/nedb?tab=readme-ov-file#inserting-documents

Author
  • BigfootDS

(async) insertOne

Create a singular new document within a specified collection, as per the NeDB documentation.

https://github.com/seald/nedb?tab=readme-ov-file#inserting-documents

Author
  • BigfootDS

(async) removeDatabase

Remove all database data from the filesystem. This means that all documents within this NeDB client instance's collections are removed, all collection objects on the NeDB client instance are removed, and all .db files relevant to this NeDB client instance are removed from the file system.

Author
  • BigfootDS

(async) removeIndex

Remove an index on a specified collection's field(s), as per the NeDB documentation:

https://github.com/seald/nedb?tab=readme-ov-file#indexing

Author
  • BigfootDS