better README
This commit is contained in:
parent
927f205748
commit
d95d3ed714
47
README
47
README
@ -1 +1,46 @@
|
||||
A python driver for MongoDB.
|
||||
A python driver for Mongo.
|
||||
|
||||
Here is a sample interactive session showing it's basic usage. More
|
||||
documentation is available in the extensive docstrings w/in the
|
||||
project. There will be auto-generated documentation soon.
|
||||
|
||||
>>> import mongo
|
||||
|
||||
>>> db = mongo.Mongo("test", "localhost", 27017)
|
||||
|
||||
>>> db.my_collection
|
||||
Collection(Mongo('test', 'localhost', 27017), u'my_collection')
|
||||
|
||||
>>> db.my_collection.save({"x": 10})
|
||||
ObjectId('\xe8\xc6M\x89+\xf3\x9b\xc0D\x10\xca\xe7')
|
||||
|
||||
>>> db.my_collection.save({"x": 8})
|
||||
ObjectId('\xa0\xbe\xe5M\xbbm\r\xc8\x9e\x9d\xe8^')
|
||||
|
||||
>>> db.my_collection.save({"x": 11})
|
||||
ObjectId('#`\x02\x8d\xfc}\x9a>\x87\x8b\x99\xb9')
|
||||
|
||||
>>> db.my_collection.find_one()
|
||||
SON([(u'x', 10), (u'_id', ObjectId('\xe8\xc6M\x89+\xf3\x9b\xc0D\x10\xca\xe7'))])
|
||||
|
||||
>>> for item in db.my_collection.find():
|
||||
... print item["x"]
|
||||
...
|
||||
10
|
||||
8
|
||||
11
|
||||
|
||||
>>> db.my_collection.create_index("x", mongo.ASCENDING)
|
||||
|
||||
>>> for item in db.my_collection.find().sort("x", mongo.ASCENDING):
|
||||
... print item["x"]
|
||||
...
|
||||
8
|
||||
10
|
||||
11
|
||||
|
||||
>>> for item in db.my_collection.find().limit(2).skip(1):
|
||||
... print item["x"]
|
||||
...
|
||||
8
|
||||
11
|
||||
|
||||
Loading…
Reference in New Issue
Block a user