Class/Object

io.scalajs.npm.mongoose

MongooseModel

Related Docs: object MongooseModel | package mongoose

Permalink

class MongooseModel[T] extends Object

Mongoose Model

Annotations
@RawJSType() @native()
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MongooseModel
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MongooseModel(doc: Any, fields: Array[String] = js.native, skipId: Boolean = js.native)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. var $where: Any

    Permalink

    Additional properties to attach to the query when calling save() and isNew is false.

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def aggregate[A](pipeline: Any, callback: MongooseCallback[A]): Unit

    Permalink

    Performs aggregations on the models collection.

    Performs aggregations on the models collection.

    pipeline

    aggregation pipeline operator(s) or operator array

    callback

    the callback

    Example:
    1. aggregate([...], [callback])

  6. def aggregate[A](pipeline: Any): Aggregate[A]

    Permalink

    Performs aggregations on the models collection.

    Performs aggregations on the models collection.

    pipeline

    aggregation pipeline operator(s) or operator array

    returns

    the Aggregate

    Example:
    1. aggregate([...], [callback])

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def base: String

    Permalink

    Base Mongoose instance the model uses.

  9. def baseModelName: String

    Permalink

    If this is a discriminator model, baseModelName is the name of the base model.

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def collection: Any

    Permalink

    Collection the model uses.

  12. def count(conditions: Any, callback: Function2[MongooseError, Int, Any]): Unit

    Permalink

    Counts number of matching documents in a database collection.

    Counts number of matching documents in a database collection.

    conditions

    the given query/conditions

    callback

    the callback

    Example:
    1. count(conditions, [callback])

  13. def count(conditions: Any): Promise[Int]

    Permalink

    Counts number of matching documents in a database collection.

    Counts number of matching documents in a database collection.

    conditions

    the given query/conditions

    returns

    the promise of the count

    Example:
    1. count(conditions, [callback])

  14. def create(docs: Array[T], callback: MongooseCallback[Array[T]]): Unit

    Permalink

    Shortcut for saving one or more documents to the database.

    Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.

    docs

    a document or array of documents

    callback

    the callback

  15. def create(doc: T, callback: Function2[MongooseError, T, Any]): Unit

    Permalink

    Shortcut for saving one or more documents to the database.

    Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.

    doc

    a document or array of documents

    callback

    the callback

  16. def create(docs: Array[T]): Promise[Array[T]]

    Permalink

    Shortcut for saving one or more documents to the database.

    Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.

    docs

    an array of documents to create

    returns

    the created documents

  17. def create(doc: T): Promise[T]

    Permalink

    Shortcut for saving one or more documents to the database.

    Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.

    doc

    a document to create

    returns

    the created documents

  18. def db: Connection

    Permalink

    Connection the model uses.

  19. def discriminator(name: String, schema: Schema[T]): Unit

    Permalink

    Adds a discriminator type.

    Adds a discriminator type.

    name

    the discriminator model name

    schema

    the discriminator model schema

  20. def discriminators: Any

    Permalink

    Registered discriminators for this model.

  21. def distinct(field: String, callback: MongooseCallback[Array[T]]): Unit

    Permalink

    Creates a Query for a distinct operation.

    Creates a Query for a distinct operation.

    field

    the field

    callback

    the callback

  22. def distinct(field: String, conditions: Any, callback: MongooseCallback[Array[T]]): Unit

    Permalink

    Creates a Query for a distinct operation.

    Creates a Query for a distinct operation.

    field

    the field

    conditions

    the optional condition

    callback

    the callback

  23. def distinct(field: String, conditions: Any = js.native): Query[Array[T]]

    Permalink

    Creates a Query for a distinct operation.

    Creates a Query for a distinct operation.

    field

    the field

    conditions

    the optional condition

    returns

    the resulting query

  24. val doc: Any

    Permalink
  25. def ensureIndexes(options: RawOptions, calback: Function1[MongooseError, Any]): Unit

    Permalink

    Sends ensureIndex commands to mongo for each index declared in the schema.

    Sends ensureIndex commands to mongo for each index declared in the schema.

    options

    the internal options

    calback

    the optional callback

  26. def ensureIndexes(options: RawOptions): Promise[Unit]

    Permalink

    Sends ensureIndex commands to mongo for each index declared in the schema.

    Sends ensureIndex commands to mongo for each index declared in the schema.

    options

    the internal options

    returns

    a promise of the completion

  27. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  28. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  29. val fields: Array[String]

    Permalink
  30. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  31. def find(conditions: Any, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Finds documents

    Finds documents

    conditions

    the given conditions/query

    callback

    the optional callback

  32. def find(conditions: Any): Query[Array[Model[T]]]

    Permalink

    Finds documents

    Finds documents

    conditions

    the given conditions/query

    returns

    a Query

  33. def findById(id: |[|[ObjectId, String], Int], callback: MongooseModelCallback[T]): Unit

    Permalink

    Finds a single document by its _id field.

    Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().

    id

    the value of _id to query by

    callback

    the optional callback

  34. def findById(id: |[|[ObjectId, String], Int], projection: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Finds a single document by its _id field.

    Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().

    id

    the value of _id to query by

    projection

    the optional fields to return

    callback

    the optional callback

  35. def findById(id: |[|[ObjectId, String], Int], projection: RawOptions = js.native): Query[Model[T]]

    Permalink

    Finds a single document by its _id field.

    Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().

    id

    the value of _id to query by

    projection

    the optional fields to return

    returns

    the Query

  36. def findByIdAndRemove(id: |[|[ObjectId, String], Int], callback: MongooseModelCallback[T]): Unit

    Permalink

    Issue a mongodb findAndModify remove command by a document's _id field.

    Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).

    id

    the value of _id to query by

    callback

    the optional callback

    Example:
    1. findByIdAndRemove(id, [options], [callback])

  37. def findByIdAndRemove(id: |[|[ObjectId, String], Int], options: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issue a mongodb findAndModify remove command by a document's _id field.

    Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).

    id

    the value of _id to query by

    options

    the optional options

    callback

    the optional callback

    Example:
    1. findByIdAndRemove(id, [options], [callback])

  38. def findByIdAndRemove(id: |[|[ObjectId, String], Int], options: RawOptions = js.native): Promise[Model[T]]

    Permalink

    Issue a mongodb findAndModify remove command by a document's _id field.

    Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).

    id

    the value of _id to query by

    options

    the optional options

    returns

    a promise of the results

    Example:
    1. findByIdAndRemove(id, [options], [callback])

  39. def findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issues a mongodb findAndModify update command by a document's _id field.

    Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).

    id

    the value of _id to query by

    update

    the update sub-document

    options

    the optional options

    callback

    the optional callback

  40. def findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issues a mongodb findAndModify update command by a document's _id field.

    Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).

    id

    the value of _id to query by

    update

    the update sub-document

    callback

    the optional callback

  41. def findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, options: RawOptions = js.native): Promise[Model[T]]

    Permalink

    Issues a mongodb findAndModify update command by a document's _id field.

    Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).

    id

    the value of _id to query by

    update

    the update sub-document

    options

    the optional options

    returns

    the promise of the document

  42. def findOne(conditions: Any, projection: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Finds one document.

    Finds one document.

    conditions

    the conditions/query

    projection

    the optional fields to return

    callback

    the option callback

  43. def findOne(conditions: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Finds one document.

    Finds one document.

    conditions

    the conditions/query

    callback

    the option callback

  44. def findOne(conditions: Any, projection: Any = js.native): Query[Model[T]]

    Permalink

    Finds one document.

    Finds one document.

    conditions

    the conditions/query

    projection

    the optional fields to return

    returns

    the Query

  45. def findOneAndRemove(conditions: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issue a mongodb findAndModify remove command.

    Issue a mongodb findAndModify remove command.

    conditions

    the conditions/query

    callback

    the option callback

  46. def findOneAndRemove(conditions: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issue a mongodb findAndModify remove command.

    Issue a mongodb findAndModify remove command.

    conditions

    the conditions/query

    options

    the optional options

    callback

    the option callback

  47. def findOneAndRemove(conditions: Any, options: RawOptions = js.native): Promise[Model[T]]

    Permalink

    Issue a mongodb findAndModify remove command.

    Issue a mongodb findAndModify remove command.

    conditions

    the conditions/query

    options

    the optional options

    returns

    the promise of the removed document

  48. def findOneAndUpdate(conditions: Any, update: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issues a mongodb findAndModify update command.

    Issues a mongodb findAndModify update command.

    conditions

    the conditions/query

    update

    the sub-document update

    callback

    the option callback

  49. def findOneAndUpdate(conditions: Any, update: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Issues a mongodb findAndModify update command.

    Issues a mongodb findAndModify update command.

    conditions

    the conditions/query

    update

    the sub-document update

    options

    the optional options

    callback

    the option callback

  50. def findOneAndUpdate(conditions: Any, update: Any, options: RawOptions = js.native): Promise[Model[T]]

    Permalink

    Issues a mongodb findAndModify update command.

    Issues a mongodb findAndModify update command.

    conditions

    the conditions/query

    update

    the sub-document update

    options

    the optional options

    returns

    the promise of the updated document

  51. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  52. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  53. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  54. def insertMany(docs: Array[T], callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.

    docs

    the documents to insert

    callback

    the option callback

  55. def insertMany(docs: Array[T], options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.

    docs

    the documents to insert

    options

    the optional options

    callback

    the option callback

  56. def insertMany(docs: Array[T], options: RawOptions = js.native): Promise[Array[Model[T]]]

    Permalink

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.

    Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.

    docs

    the documents to insert

    options

    the optional options

    returns

    a promise of the inserted documents

  57. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  58. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  59. def mapReduce[A](obj: Any, callback: Function2[MongooseError, A, T]): Unit

    Permalink

    Executes a mapReduce command.

    Executes a mapReduce command.

    obj

    an object specifying map-reduce options

    callback

    the optional callback

  60. def mapReduce[A](obj: Any): Promise[A]

    Permalink

    Executes a mapReduce command.

    Executes a mapReduce command.

    obj

    an object specifying map-reduce options

    returns

    the promise of the results

  61. def model[A](name: String): MongooseModel[A]

    Permalink

    Returns another Model instance.

    Returns another Model instance.

    A

    the model type

    name

    the model name

    returns

    the model

  62. def modelName: String

    Permalink

    The name of the model

  63. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  64. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  65. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  66. def populate(docs: Array[T], options: Dictionary[Any], callback: MongooseModelCallback[T]): Unit

    Permalink

    Populates document references.

    Populates document references.

    docs

    Either a single document or array of documents to populate.

    options

    A hash of key/val (path, options) used for population.

    callback

    Optional callback, executed upon completion. Receives err and the doc(s).

  67. def populate(docs: Array[T], options: Dictionary[Any]): Promise[Array[Model[T]]]

    Permalink

    Populates document references.

    Populates document references.

    docs

    an array of documents to populate.

    options

    A hash of key/val (path, options) used for population.

    returns

    the doc(s).

  68. def populate(docs: T, options: Dictionary[Any], callback: MongooseModelCallback[T]): Unit

    Permalink

    Populates document references.

    Populates document references.

    docs

    Either a single document or array of documents to populate.

    options

    A hash of key/val (path, options) used for population.

    callback

    Optional callback, executed upon completion. Receives err and the doc(s).

  69. def populate(doc: T, options: Dictionary[Any]): Promise[Model[T]]

    Permalink

    Populates document references.

    Populates document references.

    doc

    a single document to populate.

    options

    A hash of key/val (path, options) used for population.

    returns

    the doc(s).

  70. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  71. def remove(conditions: Any, callback: Function2[MongooseError, UpdateWriteResult, Any]): Unit

    Permalink

    Removes documents from the collection.

    Removes documents from the collection.

    conditions

    the conditions/query

    callback

    the optional callback

  72. def remove(conditions: Any): Promise[UpdateWriteResult]

    Permalink

    Removes documents from the collection.

    Removes documents from the collection.

    conditions

    the conditions/query

    returns

    the promise of the removed document

  73. def schema: Schema[T]

    Permalink

    The Schema the model uses.

  74. val skipId: Boolean

    Permalink
  75. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  76. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  77. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  78. def update(conditions: Any, doc: Any, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Updates documents in the database without returning them.

    Updates documents in the database without returning them.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    callback

    the optional callback

  79. def update(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Updates documents in the database without returning them.

    Updates documents in the database without returning them.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    options

    the optional options

    callback

    the optional callback

  80. def update(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Array[Model[T]]]

    Permalink

    Updates documents in the database without returning them.

    Updates documents in the database without returning them.

    doc

    the sub-document to use in the update

    options

    the optional options

    returns

    the promise of the updated document

  81. def updateMany(conditions: Any, doc: Any, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    callback

    the optional callback

  82. def updateMany(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit

    Permalink

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    options

    the optional options

    callback

    the optional callback

  83. def updateMany(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Array[Model[T]]]

    Permalink

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.

    doc

    the sub-document to use in the update

    options

    the optional options

    returns

    the promise of the updated document

  84. def updateOne(conditions: Any, doc: Any, callback: MongooseModelCallback[T]): Unit

    Permalink

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    callback

    the optional callback

  85. def updateOne(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit

    Permalink

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    options

    the optional options

    callback

    the optional callback

  86. def updateOne(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Model[T]]

    Permalink

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.

    conditions

    the conditions/query

    doc

    the sub-document to use in the update

    options

    the optional options

    returns

    the promise of the updated document

  87. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  88. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  89. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  90. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  91. def where(path: String, value: Any = js.native): QueryOperator[Array[T]]

    Permalink

    Creates a Query, applies the passed conditions, and returns the Query.

    Creates a Query, applies the passed conditions, and returns the Query.

    path

    the given path/field

    value

    the optional value

    returns

    the QueryOperator

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped