У меня есть массив объектов;пример: listOfExpenses = [{...}, {...}, {...}]
, в настоящее время это пустой массив, и я хочу добавить объект в этот массив.
Я называю это так:
const chatInstance = db.collection("chats").doc("1234567");
chatInstance.update({
listOfExpenses: admin.firestore.FieldValue.arrayUnion({
amount: 10,
category: "food",
date: "2019-06-16T07:25:26.010Z"
})
});
Это ошибка, которую я получаю
FirebaseError: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom object (found in field listOfExpenses)
at new FirestoreError (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:355:28)
at ParseContext.createError (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19726:16)
at validatePlainObject (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:20111:27)
at UserDataConverter.parseData (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19912:13)
at /Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19835:41
at forEach (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:457:13)
at UserDataConverter.parseUpdateData (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19826:9)
at DocumentReference.update (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:20732:52)
at bot.command.ctx (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/index.js:127:22)
at Promise.resolve.then (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/telegraf/composer.js:128:56)
Failed to process updates. { FirebaseError: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom object (found in field listOfExpenses)
at new FirestoreError (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:355:28)
at ParseContext.createError (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19726:16)
at validatePlainObject (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:20111:27)
at UserDataConverter.parseData (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19912:13)
at /Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19835:41
at forEach (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:457:13)
at UserDataConverter.parseUpdateData (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:19826:9)
at DocumentReference.update (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/@firebase/firestore/dist/index.node.cjs.js:20732:52)
at bot.command.ctx (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/index.js:127:22)
at Promise.resolve.then (/Users/edvinsantonovs/Documents/repos/dollar-dollar-bot/node_modules/telegraf/composer.js:128:56)
code: 'invalid-argument',
name: 'FirebaseError',
toString: [Function] }
Я не совсем уверен, что я делаю не так