Hello, I have the problem with $merge stage similar to Cannot get $merge to work with node.js driver 3.5.9 in a 3rd party library, migrate-mongo.
I read the migrate-mongo
source code in GitHub, migrate-mongo
returns the db and then we can simply run await db.collection('collection-name').aggregate([/* stages */])
. but this method can not create the new collection. here is the code:
await db.collection('admins').aggregate([
{
$addFields: {
adminId: '$_id',
},
},
{
$project: {
_id: 0,
adminId: 1,
username: 1,
password: 1,
name: 1,
lastname: 1,
phoneNumber: '$info.phoneNumber',
createdAt: 1,
updatedAt: 1,
},
},
{
$addFields: {
isPhoneNumberVerified: true,
role: 'ADMIN',
gender: 'UNKNOWN',
},
},
{
$merge: {
into: 'users',
},
},
]);
but this aggregate can not create the users collection. can you help me?
can you provide me your repo/source code, I wanna read it to figure it out how you deal with $merge stage in nodejs mongodb driver.
thanks regardless
Kasir barati