Discussion:
execute nested array return empty result android n1ql query
djougue basso
2018-06-17 07:28:11 UTC
Permalink
hi i would like to very condition on array json child of document but the
result returned by the query is always empty despite the fact that there is
some elements satisfaying the condition.
consider the json:
{
"parcours": [
{
"dateArrete": null,
"dateFinService": null,
"datePriseService": "15-6-2018",
"fonction": "CHEF DES TRAVAUX",
"numeroArrete": null,
"posteActuel": true,
"structure": "",
"structureId": -1,
"typeStructure": null
},
{
"dateArrete": null,
"dateFinService": "",
"datePriseService": "",
"fonction": "",
"numeroArrete": null,
"posteActuel": false,
"structure": "",
"structureId": -1,
"typeStructure": null
}
],
"personnel": {
"LangueEnseignement": "Francais",
"address": null,
"arrondissementOrigine": "",
"arrondissementOrigineConjoint": "",
"birthDate": "15-5-2018",
"dateIntegration": "15-6-2018",
"departementOrigine": "NYONG ET KELLE",
"departementOrigineConjoint": "",
"email": null,
"etatSante": null,
"firstName": "duvduv",
"fonctionConjoint": "",
"grade": "PCEG",
"indice": null,
"langueEnseignement": "Francais",
"lastName": null,
"matricule": "d-012768",
"nbEnfant": 5,
"nbEnfantScolarise": 0,
"nomConjoint": "",
"phoneNumber": 679494639,
"picturePath": null,
"placeBirth": "bertoua",
"regionOrigine": "LT",
"regionOrigineConjoint": "",
"secondPhoneNumber": -1,
"sexe": "M",
"situationMatrimoniale": "DIVORCE(E)",
"specialite": "DROIT"
},
"type": "personnel"
}

I wrote the following android query:

VariableExpression varParcoursItem = ArrayExpression.variable("parcoursItem");
VariableExpression varParcoursItemStructureId = ArrayExpression.variable("parcoursItem.structureId");
Database database = DatabaseManager.getDatabase();


Query query = QueryBuilder
.select(SelectResult.all())
.from(DataSource.database(database))
.where(Expression.property("type").equalTo(Expression.string("personnel")
.and(ArrayExpression.any(varParcoursItem).in(Expression.property("parcours"))
.satisfies(varParcoursItemStructureId.equalTo(Expression.intValue(-1))))));


but the result returned is empty despite the fact that the previous json satifies condition. Please where is the mistake
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/5e5d1bd4-718d-4267-8513-b6cef25eeb34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...