Jump to content
新域网络技术论坛
Sign in to follow this  
Jamers

MongoDB使用过程中的记录

Recommended Posts

$where 使用示例:

db.test.find({
	"detail.test": {$nin:[null],$exists: true},
	$where: function() {
		var ret = false;
		for(var curr in this.detail.test) {
			//print(this.detail.test[curr].nums);
			if (this.detail.test[curr].nums >= 100) {
				ret = true;
				break;
			}
		}
		return ret;
	}
});

以上仅为演示使用$where的方式,上面的功能推荐用子元素匹配处理,上面的效率太低了

db.test.find({
		'detail.test': {
			'$elemMatch': {'nums': {'$gte': 100}}
		},
} 

查看print输出日志需要到服务器上直接查看日志,不推荐打开日志

tail -f /var/db/mongodb/mongod.log

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...