mongodb

  • crud
    • create: insert
      • db.collection.insert(obj)
    • update
      • update() => more general
      • save()
      • db.collection.update(<query>,<update>,<options>)
        • update: $set, $inc, $push, $pushAll, $addToSet, $pop, $pull, $pullAll
        • array
          • pop
            • use “-1” to remove the 1st element
            • use “1” to remove the last element
          • push
            • add item to existing array
            • will create new one if not exist
    • read: find, findOne
      • find return cursor
        • db.collection.find() -> return everything
        • db.collection.find(query, optionalField)
        • db.book.find({“name”:”harry porter”, “publishDate”:{“$lt”:10}})
        • db.book.find({“$or”:[]})
      • findOne return an obj
      • logical expression
        • $gt, $gte
        • $lt,$lte
        • $ne
        • $in, $nin
        • $all
        • $or
        • $not
        • $size
        • $exists
      • method
        • count()
        • distinct()
    • remove
  • can it store file?
Advertisements
This entry was posted in DB. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s