Node.js mongodb 메서드

이건선·2023년 2월 27일
0
  1. Model methods:

    • create: creates a new document and saves it to the database
    • findById: finds a document by its ID
    • findByIdAndUpdate: finds a document by its ID and updates it
    • findByIdAndDelete: finds a document by its ID and deletes it
    • findOne: finds a single document that matches the query criteria
    • findOneAndUpdate: finds a single document that matches the query criteria and updates it
    • findOneAndDelete: finds a single document that matches the query criteria and deletes it
    • updateOne: updates a single document that matches the query criteria
    • updateMany: updates all documents that match the query criteria
    • deleteOne: deletes a single document that matches the query criteria
    • deleteMany: deletes all documents that match the query criteria
    • countDocuments: counts the number of documents that match the query criteria
  2. Query methods:

    • where: specifies a query condition
    • equals: specifies an exact match query condition
    • gt: specifies a greater than query condition
    • gte: specifies a greater than or equal to query condition
    • lt: specifies a less than query condition
    • lte: specifies a less than or equal to query condition
    • in: specifies an inclusion query condition
    • nin: specifies an exclusion query condition
    • limit: limits the number of documents returned
    • skip: skips a specified number of documents
    • sort: sorts the documents based on the specified criteria
    • select: specifies the fields to include or exclude in the query results
    • populate: populates the referenced documents in a document or documents
    • exec: executes the query
  3. Document methods:

    • save: saves the document to the database
    • update: updates the document in the database
    • remove: removes the document from the database
    • set: sets the value of a document field
    • get: gets the value of a document field
    • validate: validates the document against the schema
  4. Schema methods:

    • pre: specifies middleware functions to execute before a certain event occurs
    • post: specifies middleware functions to execute after a certain event occurs
    • virtual: creates a virtual property that is not stored in the database
    • static: adds a static method to the model that can be called directly on the model
profile
멋지게 기록하자

0개의 댓글