I am attempting to write a query that removes the element from the array based on the messageId associated with said object in the array. This is submitted through curl hence the formatting, I've tried unsuccessfully a few different ways.
'{"collection":"someCollection",
"database":"someDB",
"dataSource":"someSource",
"filter": { "serverID": "someServer" },
"update":
{ "$pull": { "messages.messageId" : "VDFajqgcOQ" },
{ "messages.$.messageId" : "VDFajqgcOQ" }}}'
Curl response : malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "Invalid syntax error...") at /usr/bin/core_perl/json_pp line 59.
{"collection":"someCollection",
"database":"someDB",
"dataSource":"someSource",
"filter": { "serverID": "someServer" },
"update": {
"$pull": { "messages.$.messageId" : "VDFajqgcOQ" }}}'
Failed to update document: FunctionError: write exception: write errors: [The positional operator did not find the match needed from the query.]
The first one is just not syntactically correct the second just doesn't work the way I'd expect.
{ $pull: { messages: { messageId: "VDFajqgcOQ" } } }