Skip to content
New issue

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

Querying _User via MongoDB directly. #890

Closed
jiewmeng opened this issue Mar 7, 2016 · 6 comments
Closed

Querying _User via MongoDB directly. #890

jiewmeng opened this issue Mar 7, 2016 · 6 comments

Comments

@jiewmeng
Copy link

jiewmeng commented Mar 7, 2016

It seems like in Mongo, when I do:

> show collections;
_PushStatus
_Role
_SCHEMA
_Session
_User
...

I can see a bunch of collections. I seem to be able to query custom classes/collections fine, but when I try to query those _ classes, I get

> db._User.find().pretty()
2016-03-07T23:00:57.303+0800 E QUERY    [thread1] TypeError: db._User is undefined :
@(shell):1:1

Why is this?

@flovilmart
Copy link
Contributor

try db["_User"].find()

@gfosco gfosco closed this as completed Mar 7, 2016
@gfosco
Copy link
Contributor

gfosco commented Mar 7, 2016

Since the collections start with an underscore, it's necessary to access them as @flovilmart mentioned.

@k7n4n5t3w4rt
Copy link

This doesn't work for me.

rs-ds023438:PRIMARY> db["_User"].find() 2016-03-08T19:45:40.479+1100 E QUERY [thread1] TypeError: db._User is undefined : @(shell):1:1

UPDATE: use db.getCollection("_User").find()

@mrmarcsmith
Copy link
Contributor

db.getCollection("_User").find() is what works for me.

@nyxee
Copy link

nyxee commented Jun 25, 2017

on a similar note, how can i edit al the acls manually via mongo db... i can see this:

"_acl" : { "*" : { "w" : true }, "LZpWH2ZPlD" : { "w" : true, "r" : true } },

and this
"_acl" : { "ZMs63uh7KE" : { "w" : true, "r" : true }, "*" : { "w" : true, "r" : true } }

and i know these methods:

`var bulk = db._USer.initializeUnorderedBulkOp();
bulk.find( { status: "D" } ).update( { $set: { status: "I", points: "0" } } );
bulk.find( { item: null } ).update( { $set: { item: "TBD" } } );
bulk.execute();

db.getCollection("_User").find()`

but i can't put it together to make all my users have Public Read and Write access programatically via the mongoDb console.

@flovilmart
Copy link
Contributor

See mongodb documentation: https://docs.mongodb.com/manual/reference/method/db.collection.update/#update-specific-fields

providing the dot noted path should work: {$set: {"_acl.*": {"r": true}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants