-
Type:
Investigation
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: mongoimport
-
None
-
1,525
Currently mongoimport's merge mode will $set the entire document from a CSV. This means that it overwrites subdocuments that already exist. It might be useful to merge subdocuments. For example, this CSV:
_id,a.b,a.c 1,2,3
With this document in the database:
{
_id: 1,
a: {
d: 4
}
}
currently results in:
{
_id: 1,
a: {
b: 2,
c: 3
}
}
while we might want:
{
_id: 1,
a: {
b: 2,
c: 3,
d: 4
}
}
We can do the following to set subdocument fields:
{$set: {"a.b": 2}}
but we will need separate handling for arrays. Merging arrays would also cause an issue with ordering since the CSV specifies the exact position of elements in the array.