【发布时间】:2018-04-05 00:13:25
【问题描述】:
尝试导入以下 csv:
_id,receiver,month,accrualMonth,paymentData.bankCode,operation
573378aef3af68090023da7d,547517955021020200599440,2016-05,2016-04,41,Manual
当我在 mongo shell mongo 版本 3.4.5 中运行时
mongoimport --db mean-dev --mode=merge --collection fulfilledpayments --type csv --headerline --file ~/Downloads/\Import.csv -vvvv
它返回以下日志,但并没有真正导入:
2018-04-04T20:51:25.331-0300 using upsert fields: [_id]
2018-04-04T20:51:25.332-0300 using 0 decoding workers
2018-04-04T20:51:25.332-0300 using 1 insert workers
2018-04-04T20:51:25.332-0300 will listen for SIGTERM, SIGINT, and SIGKILL
2018-04-04T20:51:25.360-0300 filesize: 139 bytes
2018-04-04T20:51:25.361-0300 using fields: _id,receiver,month,accrualMonth,paymentData.bankCode,operation
2018-04-04T20:51:25.381-0300 connected to: localhost
2018-04-04T20:51:25.381-0300 ns: mean-dev.fulfilledpayments
2018-04-04T20:51:25.381-0300 connected to node type: standalone
2018-04-04T20:51:25.381-0300 standalone server: setting write concern w to 1
2018-04-04T20:51:25.381-0300 using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-04-04T20:51:25.381-0300 standalone server: setting write concern w to 1
2018-04-04T20:51:25.381-0300 using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-04-04T20:51:25.382-0300 got line: [573378aef3af68090023da7d 547517955021020200599440 2016-05 2016-04 41 Manual]
2018-04-04T20:51:25.384-0300 imported 1 document
但没有真正导入数据库,像这样保持不变:
{
"_id" : ObjectId("573378aef3af68090023da7d"),
"creator" : "547517955021020200599440",
"amountTransferred" : 101.79,
"externalId" : "61fa09",
"date" : ISODate("2016-05-06T16:00:00.000-03:00"),
"payments" : [
ObjectId("559363f127c09e0900b679dd"),
ObjectId("55bc4c9170b99e090093e2a8"),
ObjectId("55e5175a3b2a8e090040d4cd"),
ObjectId("560cab8bad3c6a0900275f5a"),
ObjectId("563cc8d3f2db060900a8ba81"),
ObjectId("5661033e57d24c090035b191"),
ObjectId("568eac27eaa71c090074d5b0"),
ObjectId("56b2e691ced93a0900408267"),
ObjectId("56d905cb4c830809007e8355"),
ObjectId("56fee8063cdd4d0900776fa9"),
ObjectId("5732732e5d237d09008c57e2")
],
"__v" : 0
}
如果我关闭 --collectionfulfilledpayments 参数,它会导入一个新集合,但当然不需要合并模式,因为它不包含要匹配的 _id。
【问题讨论】:
标签: mongodb mongo-shell mongoimport