推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
love
V2EX  ›  MongoDB

MongoDB中没有值的字段是设成null好呢还是干脆没有这个key好?

  •  
  •   love · Oct 25, 2013 · 7619 views
    This topic created in 4664 days ago, the information mentioned may be changed or developed.
    三个选择:
    1. 保留key,值为null
    2. 没有key(稍微省点内存)
    3. 随意混用

    对于字符串值呢, None和空串怎么存好?
    1 replies    1970-01-01 08:00:00 +08:00
    ccdjh
        1
    ccdjh  
       Oct 25, 2013
    看应用场景吧。
    你看livid的json。

    http://www.v2ex.com/api/members/show.json?username=Livid
    是使用没有key

    http://v2ex.com/api/nodes/all.json
    保留key,值为null

    当你使用json.loads的时候,是会帮你转换null的.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1081 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 17:43 · PVG 01:43 · LAX 10:43 · JFK 13:43
    ♥ Do have faith in what you're doing.