sql >> データベース >  >> NoSQL >> MongoDB

フィールドレベルの一意性制約はMongo(ose)でも引き続きサポートされていますか?

    はい、Mongooseでは引き続き一意のインデックスがサポートされています。 こちら をご覧ください およびこちら 現在のドキュメントで。

    リンクされたドキュメントの例:

    var s = new Schema({ date: { type: Date, index: { unique: true, expires: '1d' }});
    var s = new Schema({ name: { type: String, unique: true }});
    
    Schema.path('my.path').index({ unique: true, sparse: true });
    Schema.path('name').index({ unique: true });
    



    1. mongoDB updateManyは、upserttrueおよび$inをwhere条件で使用します

    2. ObjectIdをJSONにシリアル化する方法は?

    3. MongoDBでモデルの配列内の一意の値をカウントします

    4. MongoDBがクエリに非常に類似している(正確ではない)複合インデックスを使用できないのはなぜですか?