I'm listening to a node that has children with different value types, like in te picture below
How can I get the values of the nodes that contained map values indicated with red rectangle only ?
I tried to use java class containing the fields in the red rectangle, and an error shows and says "Cannot convert type String to MyObject". So I think its reading the children that have string value first!
I really think you should restructure your data to have a separate node just for the data you want to receive.
Related
How to make history score in Array
I try u make score in array like this
this my firestore
And this is my code
String uid = auth.getCurrentUser().getUid();
muridref.document(uid).update("nilai", FieldValue.arrayUnion(skortampil));
When I get the same score the array field doesn't make new Array data,
without see data there or not in array
As mentioned in the documentation Update elements in an array about this behavior:
If your document contains an array field, you can use arrayUnion() and arrayRemove() to add and remove elements. arrayUnion() adds elements to an array but only elements not already present.
Considering that, it's working as expected, since it's not adding values that are equal. So, this means that you won't be able to add values that are equal using the method arrayUnion() directly.
This other question from the Community - accessible here - indicates that for you to achieve this goal, you will need to read all the values from the array in your client side, update your values in the array outside the database and then, writing/updating it back in the database.
Let me know if the information helped you!
There's probably a better way to phrase my question.
I have an object that one of its elements should be a list of key and value pairs.
My problem is that when I save the object to firebase, the list saves each element under a node with a number key like an array.
I don't want to have that node, I want the key- value to be directly under the parent.
In my example you could see under images what I am talking about.
I've tried to define the "image" element as mutableListOf<Map<String, Boolean>> or mutableCollectionOf<Map<String, Boolean>>
E.g. I have next data in my Firebase Realtime Database (my json file contains json array of some objects):
I would like to get all objects starting from a specific index (position) to the end of this array (in Firebase DB json array is converted to simple object which contains children with keys 001, 002 and so on)
So I need something like this but for Firebase query:
list.subList(10, list.size)
I know there are limitToFirst, limitToLast methods but it's different
fireDatabaseReference.child("episodes").limitToLast(10)
It won't do what I need. Because I need to know the size of this array and I need to be sure that this array won't become bigger at the moment someone makes such request (at some point this array can get become bigger due to adding new objects)
Would be great to have a method like from to get all children from 10 to the end (so first 9 children are excluded):
fireDatabaseReference.child("episodes").from(10)
But there is no such method
Is there any solution for this?
Solved :)
fireDatabaseReference.child("episodes").orderByKey().startAt("10")
I have a Place object, containing an array with objectIds for Tag objects.
An example of an array:
[[{"__type":"Pointer","className":"FavoriteTag","objectId":"Toc5sVlzVd"},{"__type":"Pointer","className":"FavoriteTag","objectId":"cUxcl0IFFv"}]]
My first workflow way too slow:
query each Place object, get the array and parse it to find each objectId
get the corresponding Place with the objectId
The workflow I'm trying:
Find the objectId of each matching Tag object
Put these objectIds in a ArrayList
Get each Place object that contains a matching objectId from the arraylist
I don't know how to do step 3.
I'm trying:
parseQueryFavoritePlaces.whereEqualTo("tags", arrayListTagsObjectIds);
and
parseQueryFavoritePlaces.whereContainedIn("tags", arrayListTagsObjectIds);
but no luck so far.
Am I on the right track here?
Try giving this a shot:
query.whereContainedIn(String key, Collection<? extends Object> values)
According to the Parse documentation this adds a constraint to the query that requires a particular key's value to be contained in the provided list of values.
Here's the ParseQuery documentation if you think that might be useful!
I have one json file, that I imported in parse.com->data browser->import partition. I can get the String and image value from the table but I have no idea about how to get following values. First column have name chapters of type array look like one field following,
[{"__type":"Pointer","className":"Chapter","objectId":"BCr3uAnapV"}]
how to get above value and second column have, name user of type object look like following,
{"password":"xxx"}
Please any one help me for above, I have tried Googling but it did not help.
EDIT:
See following screen shot: arrow display column 1) chapter and have another column 2) user I want to fetch (get ) that for e.g. if we want to get data of String type like: String provider = (String) objectList.get(i).get("provider"); this manner this way I want to above data, below my screen shot:
This line is a relation (of type Pointer) to another Class in Parse:
[{"__type":"Pointer","className":"Chapter","objectId":"BCr3uAnapV"}]
The class being Chapter. You can make sure this object is fetched together with the object pointing to it using "include":
query.include("chapter");
When you query for the other object, using query.include on pointer relations will ensure these related objects are fetched as well.