将数据数组临时存储在Firestore中 [英] Temporarily store array of data in Firestore
问题描述
I have a collection of urls in an array that I need to parse through using a Firebase Cloud Function. Instead of iterating through the URL's on the client (I could potentially have hundreds of items in this array) and making individual requests to the function, I'd rather store the entire array in Firestore, pass the ID of the collection to the function, grab the array on the server, iterate through it and perform some operations, and then either save it back to Firestore with a new ID and respond back to the client with that ID so it can consume/destroy, or just respond with an newly mutated array (not sure which one I'd like to use yet).
似乎没有一种首选"的方式将阵列存储在Firebase中,因为通常认为它是邪恶的,但是,如果我不打算长时间保留数据该怎么办?
There doesn't seem to be a "preferred" way to store arrays with Firebase since it's generally considered evil, however, what if I don't plan to keep the data around for very long?
推荐答案
我建议将数组数据写为类似Java的列表:
I would suggest writing array data as a list like this Java:
myDoc.put("urls", Arrays.asList("url1", "url2", "url2"));
这将导致
urls
0: "url1"
1: "url2"
2: "url3"
这篇关于将数据数组临时存储在Firestore中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!