A first time meetup in South Jersey at the Fire Hall in Pennsauken. With some great support from 10gen with info sheets, stickers and pizza.
Notes from A. Riveria presentation:
- Document Data Model
- Database Technology anywhere…
- Written in C++
- Source Code on Github
- Runs on most platforms
- BSON (Binary JSON) – binary-encoded serialization
- JSON collections
- Embedding of objects/arrays
- Table => Collection
- Row => Document
- Join => Embedded
- Foreign Key => Reference / Link (Object Id – autogenerated serial # for each document)
- Partition => Shard (Shard keys across nodes)
- Indexes on fields and collections of indexes
- Great for lat/long
- Geospatial queries
Insert
var insertString = {username:”smith”, value:1}
can use quotes around the fieldnames.
db.users.insert(insertString);
(users is our collection)
db.users.update({username: “jones”}, {$set: {email:”a@yahoo.com”}}
first section is where, set part does the update on the field(s)
MAKE SURE YOU USE $SET modifier in updates.
Only updates first record it encounters.
Upserts. Update or if not found then create/insert.
db.users.remove( {username:”aname”});
deletes a document
$ne (not equal)
$lt (less than)
$lte (less than equal to)
$gt
Also supports CSV, best to do JSON, the default. Arrays in a field does not work in a CSV.
mongoimport –db sjmug -c users -v –file data.json –host localhost –port 27018 –jsonArray
Thanks to 10gen for sponsorship!