Skip to content

Instantly share code, notes, and snippets.

View smartinov's full-sized avatar
🦉
Causing Problems

Stefan Martinov smartinov

🦉
Causing Problems
View GitHub Profile
@eranation
eranation / gist:3241616
Created August 2, 2012 22:51
MongoDB Aggregation Framework way for "select count (distinct fieldName) from someTable" for large collections
//equivalent of "select count (distinct fieldName) from someTable"
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ])
@dungmanh88
dungmanh88 / backup_collection_mongo.sh
Last active January 22, 2024 07:42
Dump multiple collections of a db in mongodb
#!/bin/bash
db=<db>
collection_list="<collection1> <collection2> <collection3>"
host=127.0.0.1
port=<port>
out_prefix=/Temp
for collection in $collection_list; do
echo $collection
out_dir="${out_prefix}/${db}_${collection}/"
@roboncode
roboncode / firestore.go
Last active December 17, 2024 14:52
Firestore - GoLang Transform Struct To Map
package transform
import (
"reflect"
"strings"
"time"
)
const (
tagName = "firestore"