Tag Archives: nosql

Mongo: select data

1
2
> db.communities.find({name: "CZ CHAT"}, {"name":1, "_id":0, "communityId":1}).sort({"communityId":1}).pretty().limit(5)
{ "communityId" : NumberLong("468374361246531951"), "name" : "CZ CHAT" }

in sql it looks like:

1
select name, "communityId" from communities where name like 'CZ CHAT' order by "communityId" limit 5;

pretty () — just a formatted output.

Mongo: export data

1
mongoexport -h localhost -d portal -c communities --csv --fields name -q '{"communityId": { "$gte": 216172782113783808 } }' --out /tmp/guild_member.csv

— h host
— d database
— c collection (aka table)
— csv — format of export
— fields — comma separated list of fields
— q — query (aka select)
— out — out file