Firestore unique index or unique constraint?

前端 未结 3 1876
悲哀的现实
悲哀的现实 2020-11-30 07:53

Is it possible in Firestore to define an index with a unique constraint? If not, how is it possible to enforce uniqueness on a document field (without using document ID)?

3条回答
  •  孤街浪徒
    2020-11-30 08:30

    [Its not a perfect solution but working]

    I have done this unique key using key... I want my table to be having unique date value. so i made it key of my document. Any way i am able to get all documents

    db.collection('sensors').doc(sensorId).collection("data").doc(date).set(dataObj).then(() => {
        response.send(dataObj);
    });
    

提交回复
热议问题