V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
checgg
V2EX  ›  MongoDB

请教一个 mongodb 创建唯一索引的问题

  •  
  •   checgg · 2018-03-23 10:03:44 +08:00 · 3498 次点击
    这是一个创建于 2218 天前的主题,其中的信息可能已经有所发展或是发生改变。

    db.collection.createIndex({name:1},{unique:true})

    name:1

    这个 1 应该如何理解?

    1 条回复    2018-03-23 10:23:45 +08:00
    checgg
        1
    checgg  
    OP
       2018-03-23 10:23:45 +08:00
    已解决,没好好看文档。打扰了各位。

    The value of the field in the index specification describes the kind of index for that field. For example, a value of 1 specifies an index that orders items in ascending order. A value of -1 specifies an index that orders items in descending order. For additional index types, see index types.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1480 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:58 · PVG 07:58 · LAX 16:58 · JFK 19:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.