How can I create unique IDs for embedded documents in MongoDB?

前端 未结 6 609
北海茫月
北海茫月 2021-01-30 13:37

So I need to reference particular subdocuments uniquely from items in my collection. For instance:

User = {
    \'name\': \'jim\',
    \'documents: [
        {\         


        
6条回答
  •  不要未来只要你来
    2021-01-30 14:07

    And here's how to do it in Clojure, assuming the use of congomongo:

    (import org.bson.types.ObjectId)
    (str (ObjectId.)) ; => "12345xxxxx"
    

提交回复
热议问题