Skip to content

Instantly share code, notes, and snippets.

@HellMagic
HellMagic / mongo注意事项
Created February 27, 2016 08:33
##mongo注意事项
1.快速理解记忆各种操作符,怎么高效地查阅文档。
比较操作符:
op.$gt
op.$gte
op.$lt
op.$lte
op.$eq
op.$ne
op.$in
op.$nin
@HellMagic
HellMagic / mongo用法实例.js
Created February 25, 2016 06:52
mongo用法实例!!!
关于$in操作符的使用,官方有这么描述:
The $in operator selects the documents where the value of a field equals any value in the specified array.注意这里提到"any
value",即如果有document为{qty:[5, 10, 15]},使用db.test.find({qty: {"$in": [10, 1, 3]}})也能找到此document,因为此document的
qty数组对应的值中有一个10在提供的[10, 1, 3]数组中。
示例:db.inventory.find( { qty: { $in: [ 5, 15 ] } } ),等价于 db.invertory.find({"$or":[{qty: 5}, {qty: 15}]}),只不过
当前$or的条件作用的field是同一个field--qty--所以可以使用$in来替代。
$elemMatch的使用
示例:db.scores.find({ results: { $elemMatch: { $gte: 80, $lt: 85 } } })
@HellMagic
HellMagic / awesome-nginx.conf
Last active August 29, 2015 14:27 — forked from vjt/awesome-nginx.conf
*AWESOME* nginx configuration for Ruby/Rack web applications
#
# mmm m m mmm mmm mmm mmmmm mmm
# " # "m m m" #" # # " #" "# # # # #" #
# m"""# #m#m# #"""" """m # # # # # #""""
# "mm"# # # "#mm" "mmm" "#m#" # # # "#mm"
#
# nginx configuration For Ruby/Rack web applications
#
# Cooked up with style, care and a bit of *secret*
# nerdy spice. :-)