如何将 SQL 转换为 firestore 查询

How to convert SQL to firestore query

我有这样一条查询语句:

SELECT * FROM Customers  WHERE (@ID IS NULL OR ID = @ID) AND (@Name IS NULL OR Name = @Name)

但我不知道在 firestore 中使用它。你能帮助我吗。谢谢

// Create a reference to the cities collection
var cRef = db.collection("customers");

// Create a query against the collection.
var query = cRef.where("id", "in", [NULL,"YOURID"]).where("name", "in", [NULL,"YOURNAME"]);
query.get()
.then(function(querySnapshot) {
    querySnapshot.forEach(function(doc) {
        // doc.data() is never undefined for query doc snapshots
        console.log(doc.id, " => ", doc.data());
    });
})
.catch(function(error) {
    console.log("Error getting documents: ", error);
});