Skip to content

Instantly share code, notes, and snippets.

Avatar

Dana Groce danared

  • MongoDB
View GitHub Profile
View gist:950a58920dd96c1df5bd
local MongoClient = require("luaMongo.MongoClient")
local client = MongoClient.new("mongodb://localhost:27017/")
local exampleDatabase = client:getDatabase("exampleDB")
local exampleCollection = exampleDatabase:getCollection("exampleCollection")
-- Create document to insert.
local document_to_insert = {foo = "bar"}
-- Insert document into database
exampleCollection:insert_one(document_to_insert)
View gist:38ce2e30cef11a28fb80
db.data.find({"st" : "u103840",
"ts" : {"$gte": ISODate("1989-01-01"),
"$lt" : ISODate("1990-01-01")}})
View gist:6ab82c04c7277c640f21
db.data.find({"ts" : ISODate("2000-01-01T00:00:00Z")})
View gist:c44d11b2216b2f6f277b
db.data.find ({
"presentWeatherObservation.condition" : "99"
})
View gist:172a584fceb160aca635
db.data.aggregate ([
{ "$match" : { "airTemperature.quality" :
{ "$in" : [ "1", "5" ] } } },
{ "$group" : { "_id" : null,
"maxTemp" : { "$max" :
"$airTemperature.value" } } }
])
View gist:a1ba0aeb41267e9f4617
{
"st" : "u725053",
"ts" : ISODate("2013-06-03T22:51:00Z"),
"position" : {
"type" : "Point",
"coordinates" : [
-96.4,
39.117
]
},
View gist:38bb58d3fa2f8fc5bf7f
db.data.find({"st" : "u747940",
"ts" : ISODate("1969-07-16T12:00:00Z")})
View gist:65f55e09927127f950c4
{ "_id" : ObjectId("5063114bd386d8fadbd6b004"),
"name" : "Brian D. Goodman",
"organizations" : ["MongoDB”],
"locations" : [
{ "type" : "work",
"address" : "229 W 34 St., 5th floor",
"city" : "New York",
"state" : "NY",
"zipcode" : "10036"
}
View gist:bc764127c3ff77880637
{"_id" : ObjectId("5063114bd386d8fadbd6b004"),
"name" : "Brian D. Goodman",
"organizations" : ["MongoDB"],
"locations" : [
{ "type" : "work",
"address" : "229 W 34 St., 5th floor",
"city" : "New York",
"state" : "NY",
"zipcode" : "10036"
}
View gist:dbd03635a02d0422e955
{
"_id" : ObjectId("5063114bd386d8fadbd6b004"),
"name" : "Brian D. Goodman",
"organizations" : ["MongoDB"],
"locations" : [
{ "type" : "work",
"address" : "229 W 34 St., 5th floor",
"city" : "New York",
"state" : "NY",
"zipcode" : "10036"