Şeması güncellenmiyorsa Zaman damgaları:MongoDB/Gelincik
var schema = new Schema({...}, {
timestamps: true,
id: false,
toJSON: {
virtuals: true,
},
toObject: {
virtual: true,
}
});
schema.virtual('updated').get(function() {
if(typeof this.updatedAt === "undefined" && typeof this.createdAt === "undefined") return "";
var updated = (typeof this.updatedAt === "undefined") ? this.createdAt : this.updatedAt;
return "Updated "+moment(updated).fromNow();
});
Bu kod son zamanlarda çalışan oldu - updatedAt belirli örneği için 24 Ağustos olarak çıkageldi, ancak herhangi bir yeni düzenleme belgeye güncellemesi yok zaman damgası.
Burada çok saçma bir şey eksik gibi hissediyorum.
var schema =new Schema({..},
{ timestamps: { createdAt: 'createdDate',updatedAt: 'updatedDate' }
});
için: koşul false
hep
schema.virtual('updated').get(function() {
if(typeof this.updatedAt === undefined && typeof this.createdAt === undefined) return "";
var updated = (typeof this.updatedAt === undefined) ? this.createdAt : this.updatedAt;
return "Updated "+moment(updated).fromNow();
});
, bu
Bu.updatedAt türünü kontrol edebilir misiniz? – abdulbarik
@abdulbarik typeof league.updatedAt => object –
Kopyaladığınız kodu kopyalayıp sunucumda çalışıyorum ve mongoose 4.6.1 ile gayet iyi çalışıyor, Yani başka bir yerde eksik olabilirsiniz. Lütfen kullandığınız mongoose sürümünü veya herhangi bir fongoose eklentisini belirtin. –