2 / 2
Jan 20

Hello, I’ve tried used php library bulk upsert data value “$$ emoji” has throw error.
I also tried data value “$ emoji” also got unable to upsert.

Below is the code example.

$uri = 'mongodb://localhost:27017/?retryWrites=true&w=majority'; $client = new \MongoDB\Client($uri); $collection = $client->selectDatabase('test')->test; $result = $collection->bulkWrite([ [ 'updateOne' => [ [ 'unique_id' => '249993de9982967b2950a42ad651e2d7' ], [ [ '$set' => [ 'remark' => '$$ emoji' ] ] ], [ 'upsert' => true ] ] ] ]);
db.test.bulkWrite([ { "updateOne": { "filter": {"unique_id": "b4f5393a3a7f822eabd3d6eead66e533"}, "update": [ { "$set": { "remark": "$$ emoji" } } ], "upsert": true } } ]);
1 year later

I have had the same problem recently after searching for possible solutions. I have come to this

db.test.bulkWrite([ { "updateOne": { "filter": {"unique_id": "b4f5393a3a7f822eabd3d6eead66e533"}, "update": [ { "$set": { "remark": { $literal: "$$ emoji" }} } ], "upsert": true } } ]);

I have carried out satisfactory tests for the case “$$ emoji” and “$ emoji”