Android Firestore - Update object in Array leads to unsupported type
I am confused about using new firestore function
https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
In a firestore document I have the array "List" with custom objects "MyObect"
...update("TestArray", FieldValue.arrayUnion("Test"));
works fine and as expected.
But when I try this:
MyObject object = new MyObject(Value1, Value2);
...update("List", FieldValue.arrayUnion(object));
I ended up with error
java.lang.IllegalArgumentException: Invalid data. Unsupported type: com.my.app.MyObject
at com.google.firebase.firestore.core.UserData$ParseContext.createError(com.google.firebase:firebase-firestore@@17.1.3:293)
at com.google.firebase.firestore.UserDataConverter.parseScalarValue(com.google.firebase:firebase-firestore@@17.1.3:405)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:254)
at com.google.firebase.firestore.UserDataConverter.parseArrayTransformElements(com.google.firebase:firebase-firestore@@17.1.3:419)
at com.google.firebase.firestore.UserDataConverter.parseSentinelFieldValue(com.google.firebase:firebase-firestore@@17.1.3:335)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:237)
at com.google.firebase.firestore.UserDataConverter.parseUpdateData(com.google.firebase:firebase-firestore@@17.1.3:171)
at com.google.firebase.firestore.DocumentReference.update(com.google.firebase:firebase-firestore@@17.1.3:239)
EDIT
Here is my database structure:
/UserData/UserID/Data/DataSet01/
Under this path I have a few values like:
- name
- birth
- gender
- List(array)
birth gender List(array)
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("TestArray", FieldValue.arrayUnion("test"));
Adds the field "TestArray" and any given string, in the case above "test".
But the following code doesnt work:
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("List", FieldValue.arrayUnion(myObject));
add a comment |
I am confused about using new firestore function
https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
In a firestore document I have the array "List" with custom objects "MyObect"
...update("TestArray", FieldValue.arrayUnion("Test"));
works fine and as expected.
But when I try this:
MyObject object = new MyObject(Value1, Value2);
...update("List", FieldValue.arrayUnion(object));
I ended up with error
java.lang.IllegalArgumentException: Invalid data. Unsupported type: com.my.app.MyObject
at com.google.firebase.firestore.core.UserData$ParseContext.createError(com.google.firebase:firebase-firestore@@17.1.3:293)
at com.google.firebase.firestore.UserDataConverter.parseScalarValue(com.google.firebase:firebase-firestore@@17.1.3:405)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:254)
at com.google.firebase.firestore.UserDataConverter.parseArrayTransformElements(com.google.firebase:firebase-firestore@@17.1.3:419)
at com.google.firebase.firestore.UserDataConverter.parseSentinelFieldValue(com.google.firebase:firebase-firestore@@17.1.3:335)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:237)
at com.google.firebase.firestore.UserDataConverter.parseUpdateData(com.google.firebase:firebase-firestore@@17.1.3:171)
at com.google.firebase.firestore.DocumentReference.update(com.google.firebase:firebase-firestore@@17.1.3:239)
EDIT
Here is my database structure:
/UserData/UserID/Data/DataSet01/
Under this path I have a few values like:
- name
- birth
- gender
- List(array)
birth gender List(array)
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("TestArray", FieldValue.arrayUnion("test"));
Adds the field "TestArray" and any given string, in the case above "test".
But the following code doesnt work:
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("List", FieldValue.arrayUnion(myObject));
Please add your database structure to see yourTestArrayas well as yourListarray.
– Alex Mamo
Nov 21 at 9:42
add a comment |
I am confused about using new firestore function
https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
In a firestore document I have the array "List" with custom objects "MyObect"
...update("TestArray", FieldValue.arrayUnion("Test"));
works fine and as expected.
But when I try this:
MyObject object = new MyObject(Value1, Value2);
...update("List", FieldValue.arrayUnion(object));
I ended up with error
java.lang.IllegalArgumentException: Invalid data. Unsupported type: com.my.app.MyObject
at com.google.firebase.firestore.core.UserData$ParseContext.createError(com.google.firebase:firebase-firestore@@17.1.3:293)
at com.google.firebase.firestore.UserDataConverter.parseScalarValue(com.google.firebase:firebase-firestore@@17.1.3:405)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:254)
at com.google.firebase.firestore.UserDataConverter.parseArrayTransformElements(com.google.firebase:firebase-firestore@@17.1.3:419)
at com.google.firebase.firestore.UserDataConverter.parseSentinelFieldValue(com.google.firebase:firebase-firestore@@17.1.3:335)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:237)
at com.google.firebase.firestore.UserDataConverter.parseUpdateData(com.google.firebase:firebase-firestore@@17.1.3:171)
at com.google.firebase.firestore.DocumentReference.update(com.google.firebase:firebase-firestore@@17.1.3:239)
EDIT
Here is my database structure:
/UserData/UserID/Data/DataSet01/
Under this path I have a few values like:
- name
- birth
- gender
- List(array)
birth gender List(array)
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("TestArray", FieldValue.arrayUnion("test"));
Adds the field "TestArray" and any given string, in the case above "test".
But the following code doesnt work:
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("List", FieldValue.arrayUnion(myObject));
I am confused about using new firestore function
https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
In a firestore document I have the array "List" with custom objects "MyObect"
...update("TestArray", FieldValue.arrayUnion("Test"));
works fine and as expected.
But when I try this:
MyObject object = new MyObject(Value1, Value2);
...update("List", FieldValue.arrayUnion(object));
I ended up with error
java.lang.IllegalArgumentException: Invalid data. Unsupported type: com.my.app.MyObject
at com.google.firebase.firestore.core.UserData$ParseContext.createError(com.google.firebase:firebase-firestore@@17.1.3:293)
at com.google.firebase.firestore.UserDataConverter.parseScalarValue(com.google.firebase:firebase-firestore@@17.1.3:405)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:254)
at com.google.firebase.firestore.UserDataConverter.parseArrayTransformElements(com.google.firebase:firebase-firestore@@17.1.3:419)
at com.google.firebase.firestore.UserDataConverter.parseSentinelFieldValue(com.google.firebase:firebase-firestore@@17.1.3:335)
at com.google.firebase.firestore.UserDataConverter.parseData(com.google.firebase:firebase-firestore@@17.1.3:237)
at com.google.firebase.firestore.UserDataConverter.parseUpdateData(com.google.firebase:firebase-firestore@@17.1.3:171)
at com.google.firebase.firestore.DocumentReference.update(com.google.firebase:firebase-firestore@@17.1.3:239)
EDIT
Here is my database structure:
/UserData/UserID/Data/DataSet01/
Under this path I have a few values like:
- name
- birth
- gender
- List(array)
birth gender List(array)
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("TestArray", FieldValue.arrayUnion("test"));
Adds the field "TestArray" and any given string, in the case above "test".
But the following code doesnt work:
DocumentReference document= FirebaseFirestore.getInstance().document("UserData").collection("UserID").document("DataSet01");
document.update("List", FieldValue.arrayUnion(myObject));
edited Nov 21 at 20:21
asked Nov 20 at 20:24
user9365609
62
62
Please add your database structure to see yourTestArrayas well as yourListarray.
– Alex Mamo
Nov 21 at 9:42
add a comment |
Please add your database structure to see yourTestArrayas well as yourListarray.
– Alex Mamo
Nov 21 at 9:42
Please add your database structure to see your
TestArray as well as your List array.– Alex Mamo
Nov 21 at 9:42
Please add your database structure to see your
TestArray as well as your List array.– Alex Mamo
Nov 21 at 9:42
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400973%2fandroid-firestore-update-object-in-array-leads-to-unsupported-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400973%2fandroid-firestore-update-object-in-array-leads-to-unsupported-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Please add your database structure to see your
TestArrayas well as yourListarray.– Alex Mamo
Nov 21 at 9:42