私はnodejsでのMongoDBとマングースを使用しています(表現)と、すべてがこの機能を除いて、正常に動作します:マングースはフィールドで見つけることができますか?
router.get('/', function(req, res, next) {
promotions.find({active:"true"},function(err,promo){
if (err) throw err;
res.render('index',
{
promos: promo
});
});
});
それはプロモーションで空の配列に戻しますが、私は持っています私のdbの文書。
"{active:" true "}"のフィールドで問題が発生しているようです。
mongoでdb.promotions.find({active: "true"})を実行すると動作します。 。
これは私の昇進のスキーマです:
// grab the things we need
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// create a schema
var promotionSchema = new Schema({
title: String,
subtitle: String,
url: String,
image: String,
active:
{
type: Boolean,
default: false
}
});
var Promotion = mongoose.model('Promotion', promotionSchema, 'promotions');
// make this available to our Node applications
module.exports = Promotion;
これは私がMongoDBの中で得るものです:
{active:true}({"アクティブ": "true"}、{"アクティブ":true}など)のあらゆる可能な形式を試しましたが、何も機能しません。
私はdb.Promotions.find()は空を返すと思います!それをチェック! –