edit:
Structure of document:
{"tags" : ["a"], "name" : "a", "creator" : "Nick here", "users" : [ "Nick here"], "connected" : 1, "ra" : 0.3967885102611035, "_id" : ObjectId("513c3e42071a103c09000003")}
I have problem with MongoDB $pull operator. It doesn't remove value from an array. Here's my query:
db.rooms.update({users: ["Nick here"]},{$pull: {users: ["Nick here"]}})
Here's how users field looks like:
(...),"users" : [ "Nick here" ],(...)
if I write it like this:
db.rooms.update({users: "Nick here"},{$pull: {users: ["Nick here"]}})
or
db.rooms.update({users: "Nick here"},{$pull: {users: "Nick here"}})
an error is returned:
Cannot apply $pull/$pullAll modifier to non-array
What is wrong in those queries? I want to pull/push users' nicks and remove document when 'users' field is empty.
Thanks in advance, Michał
db.rooms.update({users: "Nick here"},{$pull: {users: "Nick here"}})