是否可以在mongodb中创建一个集合作为键值

时间:2017-02-09 06:44:28

标签: mongodb

我对mongodb很新。由于没有时间深入研究mongodb,我提出了这个问题。

是否可以在不使用_id的情况下以键值模式创建集合。

" 1"," 2"," 3"将作为一个关键而不是_id。

{
    "1": {
        "name": "X",
        "address": {
            "street": "abc",
            "zip": 12345
        }
    },
    "2": {
        "name": "Y",
        "address": {
            "street": "efg",
            "zip": 12346
        }
    },
    "3": {
        "name": "Z",
        "address": {
            "street": "lmn",
            "zip": 12347
        }
    }
}

编辑1: 我可以说Mongodb的收藏是一个阵列吗?

1 个答案:

答案 0 :(得分:1)

在我发现之后,似乎Mongodb的集合是一系列文档。所以,这不可能像我在问题中提到的那样。

但我可以做类似

的事情
var pc = new RTCPeerConnection();
pc.createOffer({offerToReceiveAudio: 1})
.then(function (offer) {
  let lines = offer.sdp.split('\n')
      .map(l => l.trim()); // split and remove trailing CR
  lines.forEach(function(line) {
    if (line.indexOf('a=fingerprint:') === 0) {     
      let parts = line.substr(14).split(' ');
      console.log('algorithm', parts[0]);
      console.log('fingerprint', parts[1]);
    }
  })
})
相关问题