Class NedbEmbeddedDocument

Hierarchy (view full)

Constructors

Properties

rules: {
    [key: string]: DocumentKeyRule;
}

Define your document's properties in here!

BigfootDS

Accessors

  • get collectionName(): null | string
  • 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.

    Returns null | string

    BigfootDS

  • get parentDatabaseName(): null | string
  • 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.

    Returns null | string

    BigfootDS

Methods

  • 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!

    Parameters

    • OptionaldeleteReferences: boolean

      Similar 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.

    • OptionaldeepDeleteReferences: boolean

      Similar 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.

    Returns Promise<number>

    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).

    BigfootDS

  • Save the document to the database. If the document doesn't already exist in the database, it will be added to the database automatically.

    This function also runs any preSave and postSave methods defined on the document.

    Returns Promise<boolean>

    BigfootDS

  • This document instance's data, and only the data, organized onto an object.

    This does not retrieve any referenced document's data, it's just a shallow object representation of this own document!

    Returns object

    Object containing data from the document instance.

    BigfootDS

  • Create an instance of the document's type. This does not write any data to a database.

    Type Parameters

    Parameters

    • this: (new (incomingData: object, incomingParentDatabaseName: string, incomingCollectionName: string) => Type)
        • new (incomingData, incomingParentDatabaseName, incomingCollectionName): Type
        • Parameters

          • incomingData: object
          • incomingParentDatabaseName: string
          • incomingCollectionName: string

          Returns Type

    • newData: object

      Object containing keys of data that the document requires per its schema.

    • newParentDatabaseName: string

      The name of the database/client that is managing this data.

    • newCollectionName: string

      The name of the collection that is using this document as a model for its data.

    • OptionalvalidateOnCreate: boolean = true

      Boolean flag for whether or not a document instance created with this method should be validated ASAP. Default is true.

    Returns Promise<Type>

    BigfootDS