我喜欢Mongo这样简单的事情,所以我希望利用它来做一些更先进的事情。 在我需要之前,这样做是徒劳的:
UPDATE tbl SET a = b WHERE c <> 0
a = b
part is what I can t out. 我尝试了mongodb.org,但我看不到。 页: 1 WHERE a = b,但我无法发现这两种情况。
另一种选择是,所有各行各样,而不是单独更新,但我不喜欢。 它必须更加简单。
感谢。
我喜欢Mongo这样简单的事情,所以我希望利用它来做一些更先进的事情。 在我需要之前,这样做是徒劳的:
UPDATE tbl SET a = b WHERE c <> 0
a = b
part is what I can t out. 我尝试了mongodb.org,但我看不到。 页: 1 WHERE a = b,但我无法发现这两种情况。
另一种选择是,所有各行各样,而不是单独更新,但我不喜欢。 它必须更加简单。
感谢。
You want to check the documentation for updating.
http://www.mongodb.org/display/DOCS/Updating
Your code might look like:
db.tbl.update( { c:{$ne:0}}, { $set: { a : b } } );
If you need to brush up on advanced queries (e.g. using $ne
), then check here:
http://www.mongodb.org/display/DOCS/Advanced+Queries
EDIT:
Apparently you can t update with data from the same document.
MongoDB: Updating documents using data from the same document
<EDIT 2(用地图压缩):
var c = new Mongo();
var db = c.getDB( db )
var s = db.getCollection( s )
s.drop();
s.save({z:1,q:5});
s.save({z:11,q:55});
db.runCommand({
mapreduce: s ,
map:function(){
var i = this._id; //we will emit with a unique key. _id in this case
this._id=undefined; //strange things happen with merge if you leave the id in
//update your document with access to all fields!
this.z=this.q;
emit(i,this);
},
query:{z:1}, //apply to only certain documents
out:{merge: s } //results get merged (overwrite themselves in collection)
});
//now take a look
s.find();
I m deciding between go for a NON-SQL engine or a regular SQL one for a document managment system for small bussines. I have experience with firebird/sql server and found a good track of reliability (...
I think read somewhere that when a View is requested the "map" is only run across documents that have been added since the last time it was requested? How is this determined? I thought I saw something ...
I m working on an application where data size and SQL queries are going to be heavy. I am thinking between Cassandra or Amazon SimpleDB. Can you please suggest which is more suitable in this kind of ...
Just came across this article about NOSQL patterns (not mine). It s covers lots of NOSQL implementation patterns, from a developers point of view (like hashing and replication patterns). All in all ...
Let s say I m writing a log analysis application. The main domain object would be a LogEntry. In addition. users of the application define a LogTopic which describes what log entries they are ...
I ve been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I m considering switching to a NoSQL datastore with an ...
I want to play with Riak http://riak.basho.com/ or a least get it running on a Windows system. I have downloaded the source code and compiled it but that s where I get stuck, how do I start it?
I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...