MongoDB试用记录

MongoDB试用记录

MongoDB是一种著名的NoSQL数据库。

操作系统:RHEL5.4

MongoDB版本:2.0.0

 

下载MonoDB并解压

[root@sunrise16 setup]# wget "http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.0.tgz"
--2011-10-20 12:56:36--  http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.0.tgz
正在解析主机 fastdl.mongodb.org... 216.137.45.220, 216.137.45.22, 216.137.45.29, ...
Connecting to fastdl.mongodb.org|216.137.45.220|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:37949452 (36M) [application/x-tar]
Saving to: `mongodb-linux-i686-2.0.0.tgz'

100%[==========================================================================================>] 37,949,452  44.6K/s   in 8m 6s  

2011-10-20 13:04:44 (76.2 KB/s) - `mongodb-linux-i686-2.0.0.tgz' saved [37949452/37949452]

[root@sunrise16 setup]#

 

[root@sunrise16 setup]# tar zxf mongodb-linux-i686-2.0.0.tgz
[root@sunrise16 setup]# cd mongodb-linux-i686-2.0.0
[root@sunrise16 mongodb-linux-i686-2.0.0]# ls
bin  GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES
[root@sunrise16 mongodb-linux-i686-2.0.0]# cd bin
[root@sunrise16 bin]# ls
bsondump  mongo  mongod  mongodump  mongoexport  mongofiles  mongoimport  mongorestore  mongos  mongosniff  mongostat  mongotop

 

启动mongod

[root@sunrise16 bin]# ./mongod
./mongod --help for help and startup options
Thu Oct 20 13:05:23
Thu Oct 20 13:05:23 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 20 13:05:23
Thu Oct 20 13:05:23 [initandlisten] MongoDB starting : pid=29178 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Thu Oct 20 13:05:23 [initandlisten]
Thu Oct 20 13:05:23 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 20 13:05:23 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 20 13:05:23 [initandlisten] **       with --journal, the limit is lower
Thu Oct 20 13:05:23 [initandlisten]
Thu Oct 20 13:05:23 [initandlisten] db version v2.0.0, pdfile version 4.5
Thu Oct 20 13:05:23 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Thu Oct 20 13:05:23 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Thu Oct 20 13:05:23 [initandlisten] options: {}
Thu Oct 20 13:05:23 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Thu Oct 20 13:05:23 dbexit:
Thu Oct 20 13:05:23 [initandlisten] shutdown: going to close listening sockets...
Thu Oct 20 13:05:23 [initandlisten] shutdown: going to flush diaglog...
Thu Oct 20 13:05:23 [initandlisten] shutdown: going to close sockets...
Thu Oct 20 13:05:23 [initandlisten] shutdown: waiting for fs preallocator...
Thu Oct 20 13:05:23 [initandlisten] shutdown: closing all files...
Thu Oct 20 13:05:23 [initandlisten] closeAllFiles() finished
Thu Oct 20 13:05:23 dbexit: really exiting now
[root@sunrise16 bin]#

根据屏幕上输出的信息,克制没有创建/data/db/目录。

 

[root@sunrise16 bin]# mkdir -p /data/db/
[root@sunrise16 bin]# ./mongod         
./mongod --help for help and startup options
Thu Oct 20 13:06:31
Thu Oct 20 13:06:31 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 20 13:06:31
Thu Oct 20 13:06:31 [initandlisten] MongoDB starting : pid=29510 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Thu Oct 20 13:06:31 [initandlisten]
Thu Oct 20 13:06:31 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 20 13:06:31 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 20 13:06:31 [initandlisten] **       with --journal, the limit is lower
Thu Oct 20 13:06:31 [initandlisten]
Thu Oct 20 13:06:31 [initandlisten] db version v2.0.0, pdfile version 4.5
Thu Oct 20 13:06:31 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Thu Oct 20 13:06:31 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Thu Oct 20 13:06:31 [initandlisten] options: {}
Thu Oct 20 13:06:31 [websvr] admin web console waiting for connections on port 28017
Thu Oct 20 13:06:31 [initandlisten] waiting for connections on port 27017

 

Ctrl+C
Thu Oct 20 13:06:40 got kill or ctrl c or hup signal 2 (Interrupt), will terminate after current cmd ends
Thu Oct 20 13:06:40 [interruptThread] now exiting
Thu Oct 20 13:06:40 dbexit:
Thu Oct 20 13:06:40 [interruptThread] shutdown: going to close listening sockets...
Thu Oct 20 13:06:40 [interruptThread] closing listening socket: 5
Thu Oct 20 13:06:40 [interruptThread] closing listening socket: 6
Thu Oct 20 13:06:40 [interruptThread] closing listening socket: 7
Thu Oct 20 13:06:40 [interruptThread] removing socket file: /tmp/mongodb-27017.sock
Thu Oct 20 13:06:40 [interruptThread] shutdown: going to flush diaglog...
Thu Oct 20 13:06:40 [interruptThread] shutdown: going to close sockets...
Thu Oct 20 13:06:40 [interruptThread] shutdown: waiting for fs preallocator...
Thu Oct 20 13:06:40 [interruptThread] shutdown: closing all files...
Thu Oct 20 13:06:40 [interruptThread] closeAllFiles() finished
Thu Oct 20 13:06:40 [interruptThread] shutdown: removing fs lock...
Thu Oct 20 13:06:40 dbexit: really exiting now
[root@sunrise16 bin]#

 

 

[root@sunrise16 bin]# ./mongod --journal
Thu Oct 20 13:06:50 [initandlisten] MongoDB starting : pid=29519 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Thu Oct 20 13:06:50 [initandlisten]
Thu Oct 20 13:06:50 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 20 13:06:50 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 20 13:06:50 [initandlisten] **       with --journal, the limit is lower
Thu Oct 20 13:06:50 [initandlisten]
Thu Oct 20 13:06:50 [initandlisten] db version v2.0.0, pdfile version 4.5
Thu Oct 20 13:06:50 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Thu Oct 20 13:06:50 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Thu Oct 20 13:06:50 [initandlisten] options: { journal: true }
Thu Oct 20 13:06:50 [initandlisten] journal dir=/data/db/journal
Thu Oct 20 13:06:50 [initandlisten] recover : no journal files present, no recovery needed
Thu Oct 20 13:06:51 [initandlisten] preallocateIsFaster=true 7.24
Thu Oct 20 13:06:51 [initandlisten] preallocateIsFaster=true 7.26
Thu Oct 20 13:06:53 [initandlisten] preallocateIsFaster=true 7.22
Thu Oct 20 13:06:53 [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
Thu Oct 20 13:07:58 [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
                220200960/268435456     82%
Thu Oct 20 13:09:03 [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
                146800640/268435456     54%
                188743680/268435456     70%
                251658240/268435456     93%
Thu Oct 20 13:10:08 [initandlisten] waiting for connections on port 27017
Thu Oct 20 13:10:08 [websvr] admin web console waiting for connections on port 28017
Thu Oct 20 13:11:08 [clientcursormon] mem (MB) res:12 virt:102 mapped:0

 

下面的日志内容是在启动一个mongo客户端之后产生的。
Thu Oct 20 13:11:50 [initandlisten] connection accepted from 127.0.0.1:36877 #1
Thu Oct 20 13:14:41 [FileAllocator] allocating new datafile /data/db/test.ns, filling with zeroes...
Thu Oct 20 13:14:41 [FileAllocator] creating directory /data/db/_tmp
Thu Oct 20 13:14:45 [FileAllocator] done allocating datafile /data/db/test.ns, size: 16MB,  took 4.083 secs
Thu Oct 20 13:14:45 [FileAllocator] allocating new datafile /data/db/test.0, filling with zeroes...
Thu Oct 20 13:14:49 [FileAllocator] done allocating datafile /data/db/test.0, size: 16MB,  took 4.07 secs
Thu Oct 20 13:14:49 [FileAllocator] allocating new datafile /data/db/test.1, filling with zeroes...
Thu Oct 20 13:14:49 [conn1] build index test.foo { _id: 1 }
Thu Oct 20 13:14:49 [conn1] build index done 0 records 0.361 secs
Thu Oct 20 13:14:51 [conn1] insert test.foo 10673ms
Thu Oct 20 13:14:57 [FileAllocator] done allocating datafile /data/db/test.1, size: 32MB,  took 8.389 secs
Thu Oct 20 13:15:17 [clientcursormon] mem (MB) res:13 virt:199 mapped:32
Thu Oct 20 13:16:46 [FileAllocator] allocating new datafile /data/db/mydb.ns, filling with zeroes...
Thu Oct 20 13:16:51 [FileAllocator] done allocating datafile /data/db/mydb.ns, size: 16MB,  took 4.262 secs
Thu Oct 20 13:16:51 [FileAllocator] allocating new datafile /data/db/mydb.0, filling with zeroes...
Thu Oct 20 13:16:55 [FileAllocator] done allocating datafile /data/db/mydb.0, size: 16MB,  took 4.06 secs
Thu Oct 20 13:16:55 [FileAllocator] allocating new datafile /data/db/mydb.1, filling with zeroes...
Thu Oct 20 13:16:55 [conn1] build index mydb.things { _id: 1 }
Thu Oct 20 13:16:55 [conn1] build index done 0 records 0 secs
Thu Oct 20 13:16:55 [conn1] insert mydb.things 8330ms
Thu Oct 20 13:17:03 [FileAllocator] done allocating datafile /data/db/mydb.1, size: 32MB,  took 8.142 secs
Thu Oct 20 13:17:23 [clientcursormon] mem (MB) res:13 virt:263 mapped:64
Thu Oct 20 13:22:23 [clientcursormon] mem (MB) res:13 virt:263 mapped:64
Thu Oct 20 13:24:08 [conn1] end connection 127.0.0.1:36877

Ctrl+C
Thu Oct 20 13:24:31 got kill or ctrl c or hup signal 2 (Interrupt), will terminate after current cmd ends
Thu Oct 20 13:24:31 [interruptThread] now exiting
Thu Oct 20 13:24:31 dbexit:
Thu Oct 20 13:24:31 [interruptThread] shutdown: going to close listening sockets...
Thu Oct 20 13:24:31 [interruptThread] closing listening socket: 6
Thu Oct 20 13:24:31 [interruptThread] closing listening socket: 7
Thu Oct 20 13:24:31 [interruptThread] closing listening socket: 8
Thu Oct 20 13:24:31 [interruptThread] removing socket file: /tmp/mongodb-27017.sock
Thu Oct 20 13:24:31 [interruptThread] shutdown: going to flush diaglog...
Thu Oct 20 13:24:31 [interruptThread] shutdown: going to close sockets...
Thu Oct 20 13:24:31 [interruptThread] shutdown: waiting for fs preallocator...
Thu Oct 20 13:24:31 [interruptThread] shutdown: lock for final commit...
Thu Oct 20 13:24:31 [interruptThread] shutdown: final commit...
Thu Oct 20 13:24:31 [interruptThread] shutdown: closing all files...
Thu Oct 20 13:24:31 [interruptThread] closeAllFiles() finished
Thu Oct 20 13:24:31 [interruptThread] journalCleanup...
Thu Oct 20 13:24:31 [interruptThread] removeJournalFiles
Thu Oct 20 13:24:31 [interruptThread] shutdown: removing fs lock...
Thu Oct 20 13:24:31 dbexit: really exiting now
[root@sunrise16 bin]#
[root@sunrise16 bin]#

 

 

使用mongo命令行工具访问MongoDB

[root@sunrise16 bin]# ./mongo
MongoDB shell version: 2.0.0
connecting to: test
Thu Oct 20 13:07:54 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
[root@sunrise16 bin]# ./mongo
MongoDB shell version: 2.0.0
connecting to: test
Thu Oct 20 13:08:19 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
[root@sunrise16 bin]# ./mongo
MongoDB shell version: 2.0.0
connecting to: test
Thu Oct 20 13:08:29 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed

 


[root@sunrise16 bin]# ./mongo
MongoDB shell version: 2.0.0
connecting to: test

> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        rs.help()                    help on replica set methods
        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

 

下面的测试内容来自 http://www.mongodb.org/display/DOCS/Quickstart+Unix

> db.foo.save({x:1})
> db.foo.find()
{ "_id" : ObjectId("4e9fae4127ed834a3f8d3b1a"), "x" : 1 }

 

下面的测试内容来自 http://www.mongodb.org/display/DOCS/Tutorial
> use mydb
switched to db mydb
> j={name:'zhy'}
{ "name" : "zhy" }
> t={t:3}
{ "t" : 3 }
> db.things.save(j)
> db.things.save(t)
> db.things.find()
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
{ "_id" : ObjectId("4e9faecf27ed834a3f8d3b1c"), "t" : 3 }
> for (var i = 1; i <= 20; i++) db.things.save({x : 4, j : i});
> db.things.find()
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
{ "_id" : ObjectId("4e9faecf27ed834a3f8d3b1c"), "t" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b21"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b22"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b23"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b24"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b25"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b26"), "x" : 4, "j" : 10 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b27"), "x" : 4, "j" : 11 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "x" : 4, "j" : 12 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b29"), "x" : 4, "j" : 13 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2a"), "x" : 4, "j" : 14 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2b"), "x" : 4, "j" : 15 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2c"), "x" : 4, "j" : 16 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2d"), "x" : 4, "j" : 17 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2e"), "x" : 4, "j" : 18 }
has more
> it
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2f"), "x" : 4, "j" : 19 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b30"), "x" : 4, "j" : 20 }
> it
no cursor
> var cursor = db.things.find();
> while (cursor.hasNext()) printjson(cursor.next());
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
{ "_id" : ObjectId("4e9faecf27ed834a3f8d3b1c"), "t" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b21"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b22"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b23"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b24"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b25"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b26"), "x" : 4, "j" : 10 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b27"), "x" : 4, "j" : 11 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "x" : 4, "j" : 12 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b29"), "x" : 4, "j" : 13 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2a"), "x" : 4, "j" : 14 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2b"), "x" : 4, "j" : 15 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2c"), "x" : 4, "j" : 16 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2d"), "x" : 4, "j" : 17 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2e"), "x" : 4, "j" : 18 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2f"), "x" : 4, "j" : 19 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b30"), "x" : 4, "j" : 20 }
> db.things.find().forEach(printjson);
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
{ "_id" : ObjectId("4e9faecf27ed834a3f8d3b1c"), "t" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b21"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b22"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b23"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b24"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b25"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b26"), "x" : 4, "j" : 10 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b27"), "x" : 4, "j" : 11 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "x" : 4, "j" : 12 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b29"), "x" : 4, "j" : 13 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2a"), "x" : 4, "j" : 14 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2b"), "x" : 4, "j" : 15 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2c"), "x" : 4, "j" : 16 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2d"), "x" : 4, "j" : 17 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2e"), "x" : 4, "j" : 18 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2f"), "x" : 4, "j" : 19 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b30"), "x" : 4, "j" : 20 }
> var cursor = db.things.find();
> printjson(cursor[4]);
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "x" : 4, "j" : 3 }
> var arr = db.things.find().toArray();
> arr[5];
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "x" : 4, "j" : 4 }
> db.things.find({name:"mongo"}).forEach(printjson);
> db.things.find({name:"zhy"}).forEach(printjson);
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
> db.things.find({x:4}).forEach(printjson);
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b21"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b22"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b23"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b24"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b25"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b26"), "x" : 4, "j" : 10 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b27"), "x" : 4, "j" : 11 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "x" : 4, "j" : 12 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b29"), "x" : 4, "j" : 13 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2a"), "x" : 4, "j" : 14 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2b"), "x" : 4, "j" : 15 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2c"), "x" : 4, "j" : 16 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2d"), "x" : 4, "j" : 17 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2e"), "x" : 4, "j" : 18 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2f"), "x" : 4, "j" : 19 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b30"), "x" : 4, "j" : 20 }
> db.things.find({x:4}, {j:true}).forEach(printjson);
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "j" : 1 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1e"), "j" : 2 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1f"), "j" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b20"), "j" : 4 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b21"), "j" : 5 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b22"), "j" : 6 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b23"), "j" : 7 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b24"), "j" : 8 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b25"), "j" : 9 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b26"), "j" : 10 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b27"), "j" : 11 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "j" : 12 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b29"), "j" : 13 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2a"), "j" : 14 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2b"), "j" : 15 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2c"), "j" : 16 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2d"), "j" : 17 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2e"), "j" : 18 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b2f"), "j" : 19 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b30"), "j" : 20 }
> printjson(db.things.findOne({name:"mongo"}));
null
> printjson(db.things.findOne({name:"zhy"}));
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
> var doc = db.things.findOne({_id:ObjectId("4c2209f9f3924d31102bd84a")});
> doc
null
> var doc = db.things.findOne({_id:ObjectId("4e9faf0f27ed834a3f8d3b28")});
> doc
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b28"), "x" : 4, "j" : 12 }
> db.things.find().limit(3);
{ "_id" : ObjectId("4e9faebe27ed834a3f8d3b1b"), "name" : "zhy" }
{ "_id" : ObjectId("4e9faecf27ed834a3f8d3b1c"), "t" : 3 }
{ "_id" : ObjectId("4e9faf0f27ed834a3f8d3b1d"), "x" : 4, "j" : 1 }
> quit
function () {
    return nativeHelper.apply(quit_, arguments);
}
> exit
bye
[root@sunrise16 bin]#

 

Studio 3T无限试用:解锁MongoDB可视化工具的完整功能 本文详细介绍了如何通过无限试用方法解锁Studio 3T的完整功能,这是一款强大的MongoDB可视化工具。文章涵盖了安装配置、试用期重置原理及操作步骤,以及SQL转换、聚合管道构建等高级功能实战演示,帮助开发者高效管理MongoDB数据库。 阅读详情

相关推荐

前端宝典之七:React性能优化实战精华篇

本文主要讲解实战项目中React性能优化的方法,主要分为三个大的方面:减少不必要的组件更新、组件优化以及tree-shaking,共11个方法

franktaoge的博客 1899

正在解析主机……失败:未知的名称或服务,wget无法解析主机地址。

无法解析主机地址 在centos7系统中安装python3时出现:无法解析主机地址问题 wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz 正在解析主机 www.python.org (www.python.org)… 失败:未知的名称或服务。 wget: 无法解析主机地址 “www.python.org” 1、打开终...

qq_44739762的博客 2万+

BAPI_REPMANCONF1_CREATE_MTS实战:从MFBF事务码到精准零件反冲的代码级解析

本文深入解析了如何通过BAPI_REPMANCONF1_CREATE_MTS函数实现SAP生产模块中的零件反冲自动化。文章对比了MFBF事务码的手动操作与BAPI编程的优劣,详细拆解了函数的核心参数、数据结构、调用流程及事务控制,并提供了从数据准备到凭证获取的完整代码示例与避坑指南,帮助开发者实现高效、精准的批量投料过账。

weixin_29240343的博客 189

centos7安装mongodb

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33737774的博客 178

西门子smart能搜到cpu但连接当前IP地址失败

将ip地址改到同一网段 本机为192.168.1.119就是192.168.1.1网段,但plc在192.168.0.1网段,所以显示ip连接失败,改为同一网段192.168.1.xxx即可(为避免ip冲突尽量改到200往后最大255)如果显示这一步,那么你的物理连接是没有问题的,应当是plc和电脑并不在同一网段导致的问题。输入ipconfig 查看本机网段与plc是否为同一网段。此电脑就不在同一网段所有造成通讯失败,接下来解决这个问题。win+r打开运行,打开cmd。再次尝试,如果还是报错,那么。

weixin_62678581的博客 9860

YOLOv11涨点改进| Kimi团队 2026 |独家创新首发、注意力改进篇|爆火AttnRes残差自注意力模块,含多种创新改进,借助残差思想,缓解细节信息在传播过程中被稀释,促进YOLOv11涨点

🔥本文提出AttnRes残差自注意力模块,通过深度维度的注意力加权机制替代传统固定残差累加方式,使YOLOv11网络能自适应选择更有价值的历史层特征进行聚合。该方法缓解了浅层细节信息在深层传播过程中被稀释的问题,有效融合浅层纹理与深层语义特征,提升小目标、密集目标和复杂场景的检测能力。AttnRes还改善了深层网络的梯度分布与训练稳定性,增强模型收敛质量和泛化能力。实验表明,该模块能以较小计算开销显著提升YOLOv11的特征表达能力、检测精度和整体鲁棒性。文中详细介绍了模块结构、实现原理、优势特点

Ai缝合怪、助力小伙伴高效发论文 125

mongodb学习笔记(一)

一个菜鸟,开始mongodb的学习之路

fy1995612的专栏 922

ArcGIS实验教程——实验二十五:大型商场选址经典案例

本实验基于ArcGIS平台进行商场选址分析,综合考虑道路、居民点、停车场和已有商场四个影响因素。通过缓冲区分析建立各要素的影响范围(道路50米、居民点100米、停车场100米、已有商场500米),采用叠加分析中的相交和擦除运算确定最优选址区域。实验建立了区位评价体系,通过属性赋值(1/-1)和联合运算生成综合评价结果,并实现分级可视化显示。注意事项包括距离参数设置对结果的影响以及正确选择空间分析工具。该流程为商业选址提供了科学的GIS解决方案。

智慧空间实验室 1万+

MongoDB 安装

bash-4.2$ su密码:[root@dbserver latte]# mkdir /usr/local/MongoDB[root@dbserver latte]# cd /usr/local/src[root@dbserver src]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.0.tgz--...

熊佳佳的技术笔记 314

手把手教你学Simulink——基于Simulink的隔离型DC-DC全桥变换器移相控制建模示例

本文详细介绍了基于Simulink的全桥移相变换器(PSFB)建模与控制方法。首先分析了全桥移相拓扑在大功率应用中的优势,包括ZVS实现、高频化和小型化特点。随后给出了具体设计参数和移相控制策略,采用电压外环+移相角内环的双闭环控制架构。文章重点演示了Simulink建模步骤,包括主电路搭建、移相PWM生成和PI控制器设计,并通过满载稳态、负载阶跃和轻载测试三种场景验证了系统性能。最后总结了工程实践要点,提出自适应控制等扩展方向,强调移相控制通过精准时间管理实现高效能量转换的核心价值。

MHD0815的博客 261

uniapp微信小程序开发:解决Video播放m3u8视频流非卡顿问题,使用video视频标签播放M3U8视频流或直播流总是加载一卡一卡的体验非常差的情况【多种优化方案提升流畅度和缓冲方案示例源码】

uniapp微信小程序video播放m3u8视频流卡,uniapp video在微信小程序播放m3u8格式视频总是加载频繁卡顿,Uniapp微信小程序苹果ios真机播放m3u8很卡加载不流畅怎么办,uni-App如何解决小程序端video播放视频流M3U8格式出现卡顿情况,uniapp播放m3u8直播流卡顿如何优化?uniapp m3u8格式视频加载,.m3u8监控视频,uniapp微信小程序使用video组件播放M3U8视频卡顿,uniapp微信小程序视频播放卡顿如何解决,uniapp 打包微信小程序播放

✅ 精选推荐文章 2987

maven spring 整合mongoDb

突然来了需求 想用mongodb做聚合 于是赶紧谷百 但是过程却很艰苦 发现网上有很多 但是自己搭建起来不是版本错误就是权限不足 从网上爬取下来的有很多错误 所有决定记录下,初次使用mongodb 有很多问题,请留言交流。 mongdb使用的jar包版本 &lt;properties&gt; &lt;!--mongodb--&gt; &lt;mongodb_version&...

Artoro的博客 1142

指纹对抗指南:如何绕过Cloudflare与Akamai的5s盾与浏览器指纹检测

现在的CDN反爬技术虽然越来越强,但是道高一尺魔高一丈,只要掌握了指纹伪造、流量伪装、行为模拟这些核心技术,就可以绕过绝大多数的防护措施。对抗过程中要注意效率和成本的平衡,小规模爬取用Playwright+stealth最方便,大规模爬取用curl_cffi+代理池性价比最高,遇到验证码用打码平台或者自动识别服务,不需要死磕破解。本文介绍的方案已经在实战中验证过,可以绕过95%以上的Cloudflare/Akamai防护,成功率非常高。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 295

testRigor测试用例模板记录

testRigor测试用例模板记录。

qq_30464221的博客 798

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

工作随机记录

前言: 用了段时间。mongodb 很多记录都是不全面的。这里只是做个记录。方便以后查看 正文: 启动服务:mongod 客户端:mongo

u012762054的博客 309

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

孤荷凌寒自学python第五十五天初识MongoDb数据库

孤荷凌寒自学python第五十五天第一天初识MongoDb数据库 (完整学习过程屏幕记录视频地址在文末) 大家好,2019年新年快乐! 本来我想的是借新年第一天开始,正式尝试学习爬虫,结果今天偶然发现还有一种被更广泛使用的Nosql数据库,而且还可以在本地建构本地化的数据库服务,这就是大名鼎鼎的:mongoDB 首先访问:https://www.mongodb.com/z...

weixin_30596735的博客 151

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

SpringBoot学习笔记(九:MongoDB )

还有Java核心知识点+全套架构师学习资料和视频+一线大厂面试宝典+面试简历模板可以领取+阿里美团网易腾讯小米爱奇艺快手哔哩哔哩面试题+Spring源码合集+Java架构实战电子书+2021年最新大厂面试题。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

2401_83329402的博客 1110

Spring boot学习之MongoDB的使用

Spring boot学习之MongoDB的使用 Mongodb在做一些个人的小项目的时候我觉得还是挺不错的,因为是nosql的数据库,结合jpa使用可以做到不需要建表不需要写sql语句的效果,对于需要数据存储的小项目来说其实是很合适的。 接下来就来简单介绍一下MongoDb结合Springboot的一些基础使用,这里使用的Springboot版本是2.3.7.RELEASE,别的版本可能有些许不同,自行查找别的教程 废话少说我们直接来实战上手 第一步:导入依赖 <dependency&gt

q1763868326的博客 305

spring使用MongodbTemplate操作mongodb 数据库

1.application.properties添加配置 #MongoDb 数据库操作 spring.data.mongodb.host=localhost spring.data.mongodb.port=27017 spring.data.mongodb.authentication-database=admin spring.data.mongodb.database=test spring.data.mongodb.username=manag spring.data.mongodb.pass

frankgy01的专栏 1485

mongodb基础3

mongodb和java 加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> 加配置 spring: data: mongodb:

耗子窝 294

MongoDB学习日记 - Spring框架集成 : spring-data-mongodb

一直想写这部分,但是由于水平太差了,一直没敢写;今天就献丑把自己的实践写一下,自己以后实际开发也可以回头看看。这里贴的代码都是自己测试真实的代码。下载地址:百度云分享(spring-mongo.rar)

Duanc 的博客 1886

mongo在M1 Pro中的使用踩坑记录及解决

1.首先安装我建议使用homebrew安装,具体的教程网上应该有很多。但这里我重点介绍一下用安装包自己手动安装,首先是MongoDB网站的页面:此处需要注意:一定要下载的(我指的是m1 pro用户,其实只要是苹果芯片都应该是arm64)2.下载下来之后,双击进行一个解压(如果是新电脑可能不支持解压tgz的压缩包,你可以选择下载zip,当然你可以下载一下我的这个解压工具),激活码是9kpg,如果链接已失效,请联系我!

Alaiks的博客 152

mongodb分组查询 php,php – 按字段分组在MongoDB中不起作用

我正在尝试计算我的数据库中所有记录的总和,我需要避免重复.我写了这段代码来对记录进行分组,但它对我不起作用.$pipeline = [['$match' =>$criteria->getCondition()],['$group' =>['_id' => '$order_id','total' => ['$sum' => '$'.$column]]]];$thi...

weixin_32921023的博客 270

MongoDB 文档被delete后,如何回收磁盘空间?

在回答这个问题之前,先了解一下 MySQL InnoDB 存储引擎是如何回收磁盘空间的。假设有一张表包含 1000 万条记录,删除其中的 800 万条记录,此时 InnoDB 的磁盘空间不会自动释放。要回收磁盘空间,需要执行以下命令:登录后复制 ALTER TABLE tableName ENGINE=InnoDB;1....

weixin_32063287的博客 259

红队知识学习入门(3)Shodan使用5

学习视频来自B站UP主 泷羽sec,如涉及侵泷羽sec权马上删除文章笔记的只是方便各位师傅学习知识,以下网站涉及学习内容,其他的都与本人无关,切莫逾越法律红线,否则后果自负

Zeu_s的博客 825

MongoDB 试用

部分内容摘自 http://www.runoob.com/mongodb/mongodb-tutorial.html 什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。 在高负载的情况下,添加更多的节点,可以保证服务器性能。 MongoDB 旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB

王鹏亮 的专栏 3695
上一篇: Bash字符串处理(与Java对照) - 20.查找子串的位置
下一篇: 好资料推荐:Linux 101 Hacks 英文原版+中文版PDF下载
codingstandards
博客等级 码龄16年 12粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值