Home  >  Article  >  Database  >  MongoDB 学习笔记二

MongoDB 学习笔记二

WBOY
WBOYOriginal
2016-06-07 16:31:141054browse

#save和insert方法类似,都是插入数据,但是save当主键相同的时候会自动更新db.c1.save({_id: 1, name:'user7'});#删除name为user1的数据db.c1.remove({name:'user1'});#批量插入数据for(i=1; i20; i++) { db.c1.insert({name:'user'+i, age:i }) }#查询结构

#save和insert方法类似,都是插入数据,但是save当主键相同的时候会自动更新
db.c1.save({_id: 1, name:'user7'});
#删除name为user1的数据
db.c1.remove({name:'user1'});
#批量插入数据
for(i=1; i
    <p class="copyright">
        原文地址:MongoDB 学习笔记二, 感谢原作者分享。
    </p>
    
    


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn