根据教程所使用的moment时间转换工具,我在数据插入mongodb前使用会报错;
在数据输出时使用会报错;
在输出的路由里面进行转换替换不报错了,但却没有任何的效果
for(var i =0; i < docs.length; i++ ) {
docs[i].write.create = moment(docs[i].write.create).format('YYYY-MM-DD HH:mm:ss');
docs[i].write.update = moment(docs[i].write.update).format('YYYY-MM-DD HH:mm:ss');
}
我是个nodejs小白,希望大家别用太官方的回答,真心看不懂。
大家讲道理2017-04-17 15:29:39
Based on the information you gave, it’s difficult to determine why (or you posted the error message).
Give me an idea for troubleshooting.
1. An error is reported before inserting. Is the data type after moment consistent with the type of the database field?
2. An error is reported after insertion. Is the data type of the database consistent with the parameter types required by moment?
3. The routing you mentioned does not report an error, but it has no effect. Does the docs you use include toObject()? Without toObject(), there is no way to add properties.