“Znajdź Mongoose” Kod odpowiedzi

Findbyid Mongoose

// Find the adventure with the given `id`, or `null` if not found
await Adventure.findById(id).exec();

// using callback
Adventure.findById(id, function (err, adventure) {});

// select only the adventures name and length
await Adventure.findById(id, 'name length').exec();
Cheerful Cockroach

Mongoose gdzie

exports.generateList = function (req, res) {
    subcategories
            .find({})//grabs all subcategoris
            .where('categoryId').ne([])//filter out the ones that don't have a category
            .populate('categoryId')
            .where('active').equals(true)
            .where('display').equals(true)
            .where('categoryId.active').equals(true)
            .where('display').in('categoryId').equals(true)
            .exec(function (err, data) {
            if (err) {
                console.log(err);
                console.log('error returned');
                res.send(500, { error: 'Failed insert' });
            }

            if (!data) {
                res.send(403, { error: 'Authentication Failed' });
            }

            res.send(200, data);
            console.log('success generate List');
        });
    };
Naughty Nightingale

Znajdź Mongoose

// Find one adventure whose `country` is 'Croatia', otherwise `null`
await Adventure.findOne({ country: 'Croatia' }).exec();

// using callback
Adventure.findOne({ country: 'Croatia' }, function (err, adventure) {});

// select only the adventures name and length
await Adventure.findOne({ country: 'Croatia' }, 'name length').exec();
Alert Antelope

Znajdź Mongoose

Model.findById(id, function (err, doc) {
  if (err) ..
  doc.name = 'jason bourne';
  doc.save(callback);
});
Alert Antelope

Znajdź Mongoose

A.findOneAndRemove(conditions, options, callback) // executes
A.findOneAndRemove(conditions, options)  // return Query
A.findOneAndRemove(conditions, callback) // executes
A.findOneAndRemove(conditions) // returns Query
A.findOneAndRemove()           // returns Query
Alert Antelope

Znajdź Mongoose

A.findOneAndReplace(conditions, options, callback) // executes
A.findOneAndReplace(conditions, options)  // return Query
A.findOneAndReplace(conditions, callback) // executes
A.findOneAndReplace(conditions) // returns Query
A.findOneAndReplace()           // returns Query
Alert Antelope

Odpowiedzi podobne do “Znajdź Mongoose”

Pytania podobne do “Znajdź Mongoose”

Więcej pokrewnych odpowiedzi na “Znajdź Mongoose” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu