From 441726cce18ebc9f5934a8d59d234334ace74ac5 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Thu, 30 Sep 2021 12:44:28 +0200 Subject: [PATCH] Adds mongo queries. --- rocketchat/mongo-queries.md | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rocketchat/mongo-queries.md diff --git a/rocketchat/mongo-queries.md b/rocketchat/mongo-queries.md new file mode 100644 index 0000000..cce3aed --- /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 } } ) +``` -- GitLab