Home > OS >  Is there a way to get only User item from a collection using Mongoose DB?
Is there a way to get only User item from a collection using Mongoose DB?

Time:06-06

So this is my Schema folder:

module.exports = mongoose.model(
    'premium', 
    new mongoose.Schema({
        User: String,
        Name: String,
        Expire: Number,
        Permanent: Boolean,
    })
);

So I want to get from database only User and Name items and use it in embed on discord.js, but I am not finding any way to do so

CodePudding user response:

You can use select and specify field you want with 1 and not with 0 :

dbSchemas.SomeValue.find({}).select({ "User": 1, "Name": 1});
  • Related