惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - Vince

在ubuntu server上安装沸腾时刻环境 ubuntu中管理用户和用户组 ubuntu14.04设置静态ip ssh 返回错误 Too many authentic authentication failures for root 的时候检查 ssh 配置 ubuntu安装 laravel 过程中出现: mcrypt php extension required 的问题 | 以及composer相关问题 | Nginx安装 mongo里面根据对象字段的ID查询 db.Photo.find({'owner.$id':ObjectId('xxxx')}) , 并且使用forEach循环修改查询的数据 绝对居中对齐的好办法 blur效果,模糊效果css vitualbox 主机与虚拟机能相互访问的设置 mongo对象var_dump的时候无法显示更多数据的处理办法 mongodb lock 出毛病时解决方法 ag使用需要注意的问题 twig用法 imagick用法! symfon2 配置文件使用 + HttpRequest使用 + Global多语言解决方案 Symfony中Doctrine对应的Mongodb数据类型 data type ubuntu 下配置 开发环境 highcharts多个Y轴 IE=edge 让浏览器使用最新的渲染模式
nodejs mongodb 查询要看的文章
Vince · 2014-02-05 · via 博客园 - Vince

http://www.cnblogs.com/refactor/archive/2012/07/30/2591344.html

数组很大多数情况下可以这样理解:每一个元素都是整个键的值.

db.users.findOne({"userName":"wyx","emails":"bbb@qq.com"})能匹配到

{

userName: 'wyx',

emails:[

'aaa@qq.com',

'bbb@qq.com',

'ccc@qq.com'

]

}

MongoDB高级查询

http://www.nonb.cn/blog/mongodb-advanced-queries.html

Node+Mongoose常用查询中文文档

http://www.nonb.cn/blog/nodejs-mongoose-query-chinaese.html

推荐看这三篇 mongodb的查询,以及nodejs和mongoose联用的情况

看完mongoose的基本查询就没问题了

如何在mongodb中使用索引?

http://www.cnblogs.com/huangxincheng/archive/2012/02/29/2372699.html

MongoDB组合索引的优化

非常好的文章,将索引,排序等问题的性能优劣取舍讲的很透彻

http://www.csdn.net/article/2012-11-09/2811690-optimizing-mongodb-compound

explain方法若出现BasicCursor可以视为警告,它意味着MongoDB将对数据集做一个完全的扫描。当数据集里包含上千万条信息时,这完全是行不通的。因此要考虑加上适当的索引

常用的关键字, count, distinct, group ....

http://www.cnblogs.com/huangxincheng/archive/2012/02/21/2361205.html

mongoose中的2中操作方法,

callback and query returned

http://mongoosejs.com/docs/queries.html

Queries

Documents can be retrieved through several static helper methods of models.

Any model method which involves specifying query conditions can be executed two ways:

When a callback function:

  • is passed, the operation will be executed immediately with the results passed to the callback.
  • is not passed, an instance of Query is returned, which provides a special QueryBuilder interface for you.

Let's take a look at what happens when passing a callback:

var Person = mongoose.model('Person', yourSchema); // Query

// find each person with a last name matching 'Ghost', selecting the `name` and `occupation` fields
Person.findOne({ 'name.last': 'Ghost' }, 'name occupation', function (err, person) {
  if (err) return handleError(err);
  console.log('%s %s is a %s.', person.name.first, person.name.last, person.occupation) // Space Ghost is a talk show host.
})

Here we see that the query was executed immediately and the results passed to our callback. All callbacks in Mongoose use the pattern: callback(error, result). If an error occurs executing the query, the errorparameter will contain an error document, and result will be null. If the query is successful, the errorparameter will be null, and the result will be populated with the results of the query.

Anywhere a callback is passed to a function in Mongoose, the callback follows the patterncallback(error, results).

Now let's look at what happens when no callback is passed:

// find each person with a last name matching 'Ghost'
var query = Person.findOne({ 'name.last': 'Ghost' });

// selecting the `name` and `occupation` fields
query.select('name occupation');

// execute the query at a later time
query.exec(function (err, person) {
  if (err) return handleError(err);
  console.log('%s %s is a %s.', person.name.first, person.name.last, person.occupation) // Space Ghost is a talk show host.
})

An instance of Query was returned which allows us to build up our query. Taking this example further:

Person
.find({ occupation: /host/ })
.where('name.last').equals('Ghost')
.where('age').gt(17).lt(66)
.where('likes').in(['vaporizing', 'talking'])
.limit(10)
.sort('-occupation')
.select('name occupation')
.exec(callback);