私は Keystone でいくつかのモデルに Mongoosastic を使用していますが、それらは以下を使用して問題なく更新されます。
Test.schema.plugin(mongoosastic);
しかし、以前のすべてのエントリを取得するために、既存のコレクション ( https://github.com/mongoosastic/mongoosastic#indexing-mongoose-references ) を同期/インデックス化する文書化された方法を試すと、次のようになります。
BookSchema.plugin(mongoosastic);
var Book = mongoose.model('Book', BookSchema)
, stream = TestSchema.synchronize()
, count = 0;
stream.on('data', function(err, doc){
count++;
});
stream.on('close', function(){
console.log('indexed ' + count + ' documents!');
});
stream.on('error', function(err){
console.log(err);
});
エラーが発生します:
var TestSchema = mongoose.model('Test', Test)
^
ReferenceError: mongoose is not defined
明らかに、それはうまくいきません。すっごく私は...に置き換えmongoose.model
てみましたkeystone.list
stream = keystone.list('Test').synchronize();
しかし、その後、私は散財します:
ReferenceError: Unknown keystone list {"paths":{"_id":{"path":"_id","instance":"ObjectID","validators":[],"setters":[null],"getters":[],"options":{"auto":true},"_index":null},"slug":{"enumValues":[],"regExp":null,"path":"slug","instance":"String","validators":[],"setters":[],"getters":[],"options":{"index":{"unique":true}},"_index":{"unique":true}},"createdAt":{"path":"createdAt"
次で終了:
if (!ret) throw new ReferenceError('Unknown keystone list ' + JSON.stringify(arg));
^
ReferenceError: Unknown keystone list "Test"
それは単純であるように思われる.私が欠けているものを知っている人はいますか? お願いします。どんな助けでも大歓迎です!ファンク。