Firestore Nested Array












0















I'm using a Vue action to update an array of 'Tags' saved on a document in Firestore using ArrayUnion but I'm getting the following error ...




Error: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom e object (found in field tags)




I'm using VUE and Vuetfiy with Vuex with the following dependencies ...



 "dependencies": {
"es6-promise": "^4.2.5",
"firebase": "^5.7.0",
"vee-validate": "^2.1.4",
"vue": "^2.5.17",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0",
"vuex": "^3.0.1"
},


and importing firebase as below .....



import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

const config = {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxx',
databaseURL: 'xxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxx'
}

firebase.initializeApp(config)

const firestore = firebase.firestore()
const settings = {timestampsInSnapshots: true}
firestore.settings(settings)

export const db = firebase.firestore()


My action is ....



renameCompanyTagsInUse ({commit, getters}) {
db.collection('programs').doc(getters.programId).collection('companies').doc('FzPNtNx8ndMh5P4tHhr9').update({
tags: firebase.firestore.FieldValue.arrayUnion('TestTag')})
.catch(
(error) => {
console.log(error)
}
)
commit('setTagsChanged', {oldTag: '', newTag: ''})
commit('setLoadingButton', false)
commit('setSnackbar', {status: true, text: 'Company tag updated'})
setTimeout(() => { commit('setSnackbar', [false, '...']) }, 3000)
},


The new tag 'TestTag' should be added to the array 'tags' nested in the companies doc ID FzPNtNx8ndMh5P4tHhr9










share|improve this question

























  • try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

    – Omurbek Kadyrbekov
    Jan 2 at 4:02











  • Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

    – Jayson
    Jan 2 at 4:09











  • if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

    – Omurbek Kadyrbekov
    Jan 2 at 4:19











  • Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

    – Jayson
    Jan 2 at 4:28
















0















I'm using a Vue action to update an array of 'Tags' saved on a document in Firestore using ArrayUnion but I'm getting the following error ...




Error: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom e object (found in field tags)




I'm using VUE and Vuetfiy with Vuex with the following dependencies ...



 "dependencies": {
"es6-promise": "^4.2.5",
"firebase": "^5.7.0",
"vee-validate": "^2.1.4",
"vue": "^2.5.17",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0",
"vuex": "^3.0.1"
},


and importing firebase as below .....



import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

const config = {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxx',
databaseURL: 'xxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxx'
}

firebase.initializeApp(config)

const firestore = firebase.firestore()
const settings = {timestampsInSnapshots: true}
firestore.settings(settings)

export const db = firebase.firestore()


My action is ....



renameCompanyTagsInUse ({commit, getters}) {
db.collection('programs').doc(getters.programId).collection('companies').doc('FzPNtNx8ndMh5P4tHhr9').update({
tags: firebase.firestore.FieldValue.arrayUnion('TestTag')})
.catch(
(error) => {
console.log(error)
}
)
commit('setTagsChanged', {oldTag: '', newTag: ''})
commit('setLoadingButton', false)
commit('setSnackbar', {status: true, text: 'Company tag updated'})
setTimeout(() => { commit('setSnackbar', [false, '...']) }, 3000)
},


The new tag 'TestTag' should be added to the array 'tags' nested in the companies doc ID FzPNtNx8ndMh5P4tHhr9










share|improve this question

























  • try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

    – Omurbek Kadyrbekov
    Jan 2 at 4:02











  • Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

    – Jayson
    Jan 2 at 4:09











  • if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

    – Omurbek Kadyrbekov
    Jan 2 at 4:19











  • Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

    – Jayson
    Jan 2 at 4:28














0












0








0








I'm using a Vue action to update an array of 'Tags' saved on a document in Firestore using ArrayUnion but I'm getting the following error ...




Error: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom e object (found in field tags)




I'm using VUE and Vuetfiy with Vuex with the following dependencies ...



 "dependencies": {
"es6-promise": "^4.2.5",
"firebase": "^5.7.0",
"vee-validate": "^2.1.4",
"vue": "^2.5.17",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0",
"vuex": "^3.0.1"
},


and importing firebase as below .....



import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

const config = {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxx',
databaseURL: 'xxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxx'
}

firebase.initializeApp(config)

const firestore = firebase.firestore()
const settings = {timestampsInSnapshots: true}
firestore.settings(settings)

export const db = firebase.firestore()


My action is ....



renameCompanyTagsInUse ({commit, getters}) {
db.collection('programs').doc(getters.programId).collection('companies').doc('FzPNtNx8ndMh5P4tHhr9').update({
tags: firebase.firestore.FieldValue.arrayUnion('TestTag')})
.catch(
(error) => {
console.log(error)
}
)
commit('setTagsChanged', {oldTag: '', newTag: ''})
commit('setLoadingButton', false)
commit('setSnackbar', {status: true, text: 'Company tag updated'})
setTimeout(() => { commit('setSnackbar', [false, '...']) }, 3000)
},


The new tag 'TestTag' should be added to the array 'tags' nested in the companies doc ID FzPNtNx8ndMh5P4tHhr9










share|improve this question
















I'm using a Vue action to update an array of 'Tags' saved on a document in Firestore using ArrayUnion but I'm getting the following error ...




Error: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom e object (found in field tags)




I'm using VUE and Vuetfiy with Vuex with the following dependencies ...



 "dependencies": {
"es6-promise": "^4.2.5",
"firebase": "^5.7.0",
"vee-validate": "^2.1.4",
"vue": "^2.5.17",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0",
"vuex": "^3.0.1"
},


and importing firebase as below .....



import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

const config = {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxx',
databaseURL: 'xxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxx'
}

firebase.initializeApp(config)

const firestore = firebase.firestore()
const settings = {timestampsInSnapshots: true}
firestore.settings(settings)

export const db = firebase.firestore()


My action is ....



renameCompanyTagsInUse ({commit, getters}) {
db.collection('programs').doc(getters.programId).collection('companies').doc('FzPNtNx8ndMh5P4tHhr9').update({
tags: firebase.firestore.FieldValue.arrayUnion('TestTag')})
.catch(
(error) => {
console.log(error)
}
)
commit('setTagsChanged', {oldTag: '', newTag: ''})
commit('setLoadingButton', false)
commit('setSnackbar', {status: true, text: 'Company tag updated'})
setTimeout(() => { commit('setSnackbar', [false, '...']) }, 3000)
},


The new tag 'TestTag' should be added to the array 'tags' nested in the companies doc ID FzPNtNx8ndMh5P4tHhr9







firebase vue.js google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 4:15









Phil

98.2k11144161




98.2k11144161










asked Jan 2 at 3:49









JaysonJayson

12




12













  • try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

    – Omurbek Kadyrbekov
    Jan 2 at 4:02











  • Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

    – Jayson
    Jan 2 at 4:09











  • if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

    – Omurbek Kadyrbekov
    Jan 2 at 4:19











  • Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

    – Jayson
    Jan 2 at 4:28



















  • try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

    – Omurbek Kadyrbekov
    Jan 2 at 4:02











  • Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

    – Jayson
    Jan 2 at 4:09











  • if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

    – Omurbek Kadyrbekov
    Jan 2 at 4:19











  • Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

    – Jayson
    Jan 2 at 4:28

















try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

– Omurbek Kadyrbekov
Jan 2 at 4:02





try this JSON.parse( JSON.stringify(firebase.firestore.FieldValue.arrayUnion('TestTag') ) )

– Omurbek Kadyrbekov
Jan 2 at 4:02













Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

– Jayson
Jan 2 at 4:09





Thanks OK, it did update the firestore DB but had removed all other elements in the array and nested 2 new arrays called _elements and _methodName under the tags array, which is not what I expected or am requiring

– Jayson
Jan 2 at 4:09













if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

– Omurbek Kadyrbekov
Jan 2 at 4:19





if you want to update one specific field in tags object, IMO you need to specify it. ex: { tags.values: ['word', 'cloud']}

– Omurbek Kadyrbekov
Jan 2 at 4:19













Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

– Jayson
Jan 2 at 4:28





Thank OK, but unfortunately Firestore doesn't support updates, just add and delete of items in a nested array such that I am using to track tags

– Jayson
Jan 2 at 4:28












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001001%2ffirestore-nested-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001001%2ffirestore-nested-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas