ArangoJS building filter query from a map

35 views
Skip to first unread message

Dariusz Mąkowski

unread,
Oct 15, 2022, 9:24:05 AM10/15/22
to ArangoDB
Hey

I'm trying to build a filter from a map using my filter parameters as key:value, But I keep getting error > 
```
ArangoError: AQL: syntax error, unexpected [ near '[object Object]c.name == "d2382b...' at position 1:1 (while parsing)
```
Here is my function >
```
public async getCollectionsQuery(query: Record<any, any>): Promise<Record<any, any>[]> {
const req = query["request"]
const keys = Object.keys(req)
if (keys.length) {
let rules: string = "";
for (const [key, value] of Object.entries(req)) {
rules += "c." + key + " == " + value + " AND "
}
rules = rules.substring(0, rules.length - 5)
let q = aql`
FOR c IN ${this.mCollectionPtr}
FILTER` + rules + `
RETURN c
`
console.log(q)
const cursor = await this.mDB.getDatabase().query(q)
return await cursor.all();
}
return []
}
```
Can any1 please help me up understand where I hit the wall with it? I'm lost. 
Reply all
Reply to author
Forward
0 new messages