🔬
Moonlight.DB
GitHubNPM
  • Introduction
  • Getting Started
  • Documentation
    • Database
      • createCollection()
      • deleteCollection()
      • collections
    • Collection
      • find()
      • findOne()
      • update()
      • updateOne()
      • insertOne()
      • insertMany()
      • delete()
      • deleteOne()
      • length
Powered by GitBook
On this page
  • Example
  • findOne(<filter>)

Was this helpful?

  1. Documentation
  2. Collection

findOne()

Find the first item that matches the filter

Example

db.collection("users").findOne({
    _id: "t4m1s8kuw3445ros7zz682no52e9lj91"
}).then(item => {
    console.log(item);
    /*
        item output => {
            _id: "t4m1s8kuw3445ros7zz682no52e9lj91",
            banned: false,
            accountCreated: "13/02/2023",
            example1: "example1",
            example2: "example2",
        };
    */
}).catch(error => {
    console.log("error:", error);
});

findOne(<filter>)

Parameter
Description

filter

Query for find Operation

Previousfind()Nextupdate()

Last updated 2 years ago

Was this helpful?