下面是一些我常用的mongodb命令,供自己备忘
- show dbs (列出所有数据库)
- use [database name] (数据库的切换)
- show collections (查看当前使用数据库有哪些表)
- db.[表名].find() (查找当前表下所有数据)
- db.[表名].findOne({‘key’:value}) (查找一条符合查询条件的数据)
- db.[表名].drop() (删除当前表)
- db.[表名].move({‘key’:value}) (根据条件删除数据)
- help (输出mongodb的帮助)
- db help() (数据库的帮助命令)
node与mongodb交互
1 | // 插入操作 |
1 | // 查找操作 |
1 | // 更新操作 |
1 | function deleteDocument(db, userinfo, callback) { |