2016-04-11 19 views
1

yılında Mongoosastic ile koleksiyonunu mevcut ben Mongoosastic Keystone birkaç modellerinde çalışmamasına ve kullandıkları gayet güncellemesi:Sorun indeksleme Keystonejs

Test.schema.plugin(mongoosastic); 

Ama (/ senkronize varolan koleksiyon indeksleme belgelenmiş yolu çalıştıklarında önceki tüm kayıtlarda çekmek amacıyla https://github.com/mongoosastic/mongoosastic#indexing-mongoose-references):

var TestSchema = mongoose.model('Test', Test) 
     ^

ReferenceError: mongoose is not defined 
:

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); 
}); 

bir hata alıyorum

Açıkçası, bu işe gitmeyecek, sooooo ben ... keystone.list ile

stream = keystone.list('Test').synchronize(); 

mongoose.model yerine çalıştı Ama sonra bir savurganlık olsun:

if (!ret) throw new ReferenceError('Unknown keystone list ' + JSON.stringify(arg)); 
       ^

ReferenceError: Unknown keystone list "Test" 
: ile bitirdi

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" 

Basit olması gerektiği gibi görünüyor ... Ne eksik olduğumu bilen var mı? Lütfen. Herhangi bir yardım büyük beğeni topluyor! Fanks.

var stream = TestSchema.model.synchronize() veya isterseniz kilit taşı listeden olsun:

cevap

0

Eğer TestSchema verilerinizi senkronize etmek istiyorsanız kullanmanız gereken

var stream = keystone.list('Test').model.synchronize()

sen sychronize çağırabilir Burada önemli olan sadece model üzerinde yöntem.

Bu yardımcı olur umarız!