我写了一些与默认规则完美配合的代码。代码是这样的:
import numpy as np
import tensorflow as tf
N_CHANNELS = 5
pl=tf.placeholder(dtype=tf.int32, shape=(None, 28, 28, N_CHANNELS))
# Indices we'll use. batch_size = 4 here.
label_predictions = tf.constant([0, 2, 0, 3])
# Indices of shape [?, 2], with indices[i] = [i, self.label_predictions[i]],
# which is easy to do with tf.range() and tf.stack()
indices = tf.stack([tf.range(tf.size(label_predictions)), label_predictions], axis=-1)
# [[0, 0], [1, 2], [2, 0], [3, 3]]
transposed = tf.transpose(pl, perm=[0, 3, 1, 2])
gathered = tf.gather_nd(transposed, indices) # Should be of shape (4, 2, 3)
result = tf.expand_dims(gathered, -1)
initial_value = np.arange(4*28*28*N_CHANNELS).reshape((4, 28, 28, N_CHANNELS))
sess = tf.InteractiveSession()
res = sess.run(result, feed_dict={pl: initial_value})
# print(res)
print("checking validity")
for i in range(4):
for x in range(28):
print(x)
for y in range(28):
assert res[i, x, y, 0] == initial_value[i, x, y, indices[i, 1].eval()]
print("All assertions passed")
但是如果我使用这些规则
function listenerNewMessages(chats) {
chats.forEach(function(item) {
db.collection("pm").doc(chats[0]).collection('messaggi')
.onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
if (change.type === "added" && change.doc.data().idUser != idUser && (String(Date.now()) > change.doc.id && dateChat < change.doc.id) && idChat != item) {
//alert('hai ricevuto un nuovo messaggio in '+ item)
$('#contact-'+item).removeClass('flash')
setTimeout(function(){
$('#contact-'+item).addClass('flash')
}, 50);
}
})
})
})
}
我明白了
service cloud.firestore {
match /databases/{database}/documents {
match /pm/{pm} {
allow read, write: if request.auth.uid == resource.data.partecipanti.partecipante1 || request.auth.uid == resource.data.partecipanti.partecipante2;
}
}
}
我在做什么错了?
答案 0 :(得分:0)
您需要为新写入添加request.resource
限定符。
allow read, write: if request.auth.uid == request.resource.data.some-property-A || request.auth.uid == resource.data.some-property-A;
allow read, write: if request.auth.uid == request.resource.data.some-property-B || request.auth.uid == resource.data.some-property-B;