【发布时间】:2016-08-30 20:00:34
【问题描述】:
如果我们没有在插入语句中提供值,我想在 mongodb 文档中创建当前时间作为默认值。
在 mysql 中,使用以下语句对此进行了规定。如果我们没有插入该值,则会为该行分配一个默认时间值。
create table test(name varchar(100), age varchar(10),created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
在mongodb中有没有类似的方法?我正在使用 CSV 文件中的 mongoimport 将数据导入 mongodb。因此,对于每个 CSV 行,我想要一个名为“createdAt”的额外字段,其中包含文档导入时间的值。
mongoimport -d aptigo -c employee --type csv --file /home/weavers/files/csv/Employees.csv --headerline
【问题讨论】:
标签: mongodb mongoose mongodb-query mongoimport