牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

MacPorts で mongodb をインストールして動作テストメモ

(MacOSX 10.8.3)

$ sudo port install mongodb
:
###########################################################
# A startup item has been generated that will aid in
# starting mongodb with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load mongodb
###########################################################
:
$ sudo port load mongodb
$ mongo
MongoDB shell version: 2.4.2
connecting to: test
> db
test
> show dbs
local	0.078125GB
> use mydb
switched to db mydb
> db
mydb
> show dbs
local	0.078125GB
> dbs
Sun Apr 28 12:42:17.545 JavaScript execution failed: ReferenceError: dbs is not defined
> use test
switched to db test
> db
test
> help
	db.help()                    help on db methods
	db.mycoll.help()             help on collection methods
	sh.help()                    sharding helpers
	rs.help()                    replica set helpers
	help admin                   administrative help
	help connect                 connecting to a db help
	help keys                    key shortcuts
	help misc                    misc things to know
	help mr                      mapreduce

	show dbs                     show database names
	show collections             show collections in current database
	show users                   show users in current database
	show profile                 show most recent system.profile entries with time >= 1ms
	show logs                    show the accessible logger names
	show log [name]              prints out the last segment of log in memory, 'global' is default
	use <db_name>                set current database
	db.foo.find()                list objects in collection foo
	db.foo.find( { a : 1 } )     list objects in foo where a == 1
	it                           result of the last line evaluated; use to further iterate
	DBQuery.shellBatchSize = x   set default number of items to display on shell
	exit                         quit the mongo shell
> db
test
> use mydb
switched to db mydb
> j = {name:"mongo"}
{ "name" : "mongo" }
> k={x:3}
{ "x" : 3 }
> db.things.insert(j)
> db.things.insert(k)
> show collections
system.indexes
things
> db.things.find()
{ "_id" : ObjectId("517c9ae34f43e339bf279677"), "name" : "mongo" }
{ "_id" : ObjectId("517c9ae64f43e339bf279678"), "x" : 3 }
> for (var i = 1; i <= 20; i++) db.things.insert( { x : 4 , j : i } )
> db.things.find()
{ "_id" : ObjectId("517c9ae34f43e339bf279677"), "name" : "mongo" }
{ "_id" : ObjectId("517c9ae64f43e339bf279678"), "x" : 3 }
{ "_id" : ObjectId("517c9b274f43e339bf279679"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("517c9b274f43e339bf27967a"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("517c9b274f43e339bf27967b"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("517c9b274f43e339bf27967c"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("517c9b274f43e339bf27967d"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("517c9b274f43e339bf27967e"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("517c9b274f43e339bf27967f"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("517c9b274f43e339bf279680"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("517c9b274f43e339bf279681"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("517c9b274f43e339bf279682"), "x" : 4, "j" : 10 }
{ "_id" : ObjectId("517c9b274f43e339bf279683"), "x" : 4, "j" : 11 }
{ "_id" : ObjectId("517c9b274f43e339bf279684"), "x" : 4, "j" : 12 }
{ "_id" : ObjectId("517c9b274f43e339bf279685"), "x" : 4, "j" : 13 }
{ "_id" : ObjectId("517c9b274f43e339bf279686"), "x" : 4, "j" : 14 }
{ "_id" : ObjectId("517c9b274f43e339bf279687"), "x" : 4, "j" : 15 }
{ "_id" : ObjectId("517c9b274f43e339bf279688"), "x" : 4, "j" : 16 }
{ "_id" : ObjectId("517c9b274f43e339bf279689"), "x" : 4, "j" : 17 }
{ "_id" : ObjectId("517c9b274f43e339bf27968a"), "x" : 4, "j" : 18 }
Type "it" for more
> exit
bye