const myCollection = new Mongo.Collection('myCollection'); const myDocument = myCollection.findOne({ name: 'John' }); console.log(myDocument);
const myCollection = new Mongo.Collection('myCollection'); const myDocument = myCollection.findOne({ _id: new Mongo.ObjectID('60a3fc6fa2c644b22fdc3098') }); console.log(myDocument);In this example, we use the findOne method to retrieve a document with a specific _id attribute. We create a new Mongo.ObjectID object with the _id value, and use it in the query parameter of the findOne method. Overall, this method is useful for retrieving a single document from a Mongo.Collection object given specific query parameters. It is part of the Meteor package "mongo".