I have a cloud function that invoked when a certain event happened. In the function i will get an array of string for example let h:string[] = ["foo","bar","baz"] something similar to this when I try to update an array field inside my document like this
names: admin.firestore.FieldValue.arrayUnion(h) it failed to do that and throw that error in the console
Error: 3 INVALID_ARGUMENT: Cannot convert an array value in an array value.
at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/srv/node_modules/grpc/src/client_interceptors.js:841:24)
But if i changed the code to this
names: admin.firestore.FieldValue.arrayUnion("foo","bar","baz") it works but in my function, i receive an array not the above format so it fails
Here is what I want. I have an array field in the document let call it names. when the function is triggered and I get the array from it. I want to add this array to the existing names array
before adding the array names : ["test","test2"]
after adding the array names : ["test","test2","foo","bar","baz"]
How to fix that? I'm using typescript 3.0.1