We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
According Mongodb manual I can use in either document {} or pipeline [] and it can lead to different results:
document
db.Collection.insertMany( [ {"_id" : 1, "links" : [ {link_1: "url1", link_2: "url2"} ] }, {"_id" : 2, "links" : [ {link_1: "url3", link_2: "url4"} ] } ] ) db.Collection.updateMany( {}, { "$set": {"links: {"$arrayElemAt": ["$links", 0]}} } ) db.Collection.findOne( {} ) // {_id: 1, links: {'$arrayElemAt': ['$links', 0 ] } }
pipeline
db.Collection.insertMany( [ {"_id" : 1, "links" : [ {link_1: "url1", link_2: "url2"} ] }, {"_id" : 2, "links" : [ {link_1: "url3", link_2: "url4"} ] } ] ) db.Collection.updateMany( {}, [{ "$set": {"links: {"$arrayElemAt": ["$links", 0]}} }] ) db.Collection.findOne( {} ) // {_id: 1, links: { link_1: "url1", link_2: "url2" } }
Mongolite accepts only document form of update request with consequent loose of possibility of mongo functions usage:
mongo_collection$update('{}', update = '{"$set": {"links": { "$arrayElemAt": ["$links", 0] } } }', multiple = TRUE) mongo_collection$find('{}') # {_id: 1, links: {'$arrayElemAt': ['$links', 0 ] } } mongo_collection$update('{}', update = '[{"$set": {"links": { "$arrayElemAt": ["$links", 0] } } }]', multiple = TRUE) # Error: Invalid JSON object: [{"$set": {"links": {$arrayElemAt: ["$links", 0]} } }]
I know it can be overrided by $aggregation with merge in same collection, but can you add this functionality?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
According Mongodb manual I can use in either document {} or pipeline [] and it can lead to different results:
document
pipeline
Mongolite accepts only document form of update request with consequent loose of possibility of mongo functions usage:
I know it can be overrided by $aggregation with merge in same collection, but can you add this functionality?
The text was updated successfully, but these errors were encountered: