Hi. I am wondering.
Let say I wish to create an Hashmap and save it to the DB.
Each hashMap has it’s own unique Id which I create on my app and put inside it in a field called id, for this example the id will be “123”.
In order the save it to the db, I create a new MutableDocument(“123”) and put my hashmap inside it
( newDoc.setValue(“myHash”, myHashMap); )
Also, i set newDoc.setValue(“id”, “123”);
Bottom line is that both the MutableDocument and the HashMap has the same id 123.
In order to extract my hashmap back, I can do it in three ways:
mDatabase.getDocument(“123”));
or
use query: query = QueryBuilder.select(SelectResult.all())
.from(DataSource.database(mDatabase))
.where(Expression.property(“id”).equalsTo(Expression.string(“123”)));
ResultSet res = query.execute();
Or
use query: query = QueryBuilder.select(SelectResult.all())
.from(DataSource.database(mDatabase))
.where(Expression.property(“myHash.id”).equalsTo(Expression.string(“123”)));
ResultSet res = query.execute();
The question is which which way is better? What is the best practice for it? which way is faster?
Thanks.