diff --git a/rocketchat/mongo-queries.md b/rocketchat/mongo-queries.md new file mode 100644 index 0000000000000000000000000000000000000000..cce3aed1547973ccf081693a417bb962adc3e672 --- /dev/null +++ b/rocketchat/mongo-queries.md @@ -0,0 +1,43 @@ +Query RC +==== + + +## If mongo deployed with operator + +``` +export fqdn=chat-example-org +k get secret $fqdn-app -o yaml | grep "MONGO_URL:" | cut -d" " -f4 | base64 -d +k exec -it $fqdn-rs0-2 bash +mongo --host= # line exported from secret +use rocketchat +``` + +## If not + +``` +mongo --username $MONGO_INITDB_ROOT_USERNAME --password $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin +``` + +or + +``` +mongo --username $MONGODB_CLUSTER_ADMIN_USER --password $MONGODB_CLUSTER_ADMIN_PASSWORD --authenticationDatabase admin +``` + +# Query + + +``` +db.users.count({ "lastLogin" : { $lt: new Date(), $gte: new Date(new Date().setDate(new Date().getDate()-30)) } }) + +db.users.count({ "lastLogin" : { $lt: new Date(), $gte: new Date(new Date().setDate(new Date().getDate()-360)) } }) + +db.users.count({ "active": true }) +``` + +# Users without oauth login: + + +``` +db.users.find({ "services.indiehost": { $exists: false } } ) +```