Answer the question
In order to leave comments, you need to log in
How to get only 1 value with .find in mongodb?
here is the code:
first I create an account in the database
await mongo().then(async (mongoose) => {
try {
await setSchema.insertMany( [
{ "account": account }
]);
} finally {
mongoose.connection.close()
}
})
output it
const result = await setSchema.find().limit(1);
console.log(result) outputs
:
{ _id: '5f86fbdb28740118a4dea921', account: '545:545', __v: 0 }
how to remove __v and _id ?
i.e. should be
account: '545:545'
or
545:545
Please help urgently!
Answer the question
In order to leave comments, you need to log in
https://docs.mongodb.com/manual/tutorial/project-f...
const result = await setSchema.find({}, {account: 1}).limit(1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question