AppDB Query giving inconsistent results

My AppDB query gives the correct result first time when I search a document but the very next query for that same document results nothing. And every subsequent query for that document results nothing.
This is a pattern every time I try searching a different document in AppDB.
//check if the document already exist
const appDBQuery = `{ "content.ac_page_id": { "$eq": ${pageID} } }`;
const existingPageAC = await domo.post(`/domo/datastores/v1/collections/${collectionAlias}/documents/query`, appDBQuery)
any troubleshooting suggestions?
Best Answer
-
Your code looks like its sending JSON as a string rather than sending as JSON. This might work once, but then fail if it can't be properly parsed as JSON.
Thisconst appDBQuery = `{ "content.ac_page_id": { "$eq": ${pageID} } }`;
appears to create a string. Try it as
const appDBQuery = {
"content.ac_page_id": {
"$eq": pageID // if pageID is a string, make sure it's already quoted
}
};
const existingPageAC = await domo.post(
`/domo/datastores/v1/collections/${collectionAlias}/documents/query`,
appDBQuery
);** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Answers
-
Your code looks like its sending JSON as a string rather than sending as JSON. This might work once, but then fail if it can't be properly parsed as JSON.
Thisconst appDBQuery = `{ "content.ac_page_id": { "$eq": ${pageID} } }`;
appears to create a string. Try it as
const appDBQuery = {
"content.ac_page_id": {
"$eq": pageID // if pageID is a string, make sure it's already quoted
}
};
const existingPageAC = await domo.post(
`/domo/datastores/v1/collections/${collectionAlias}/documents/query`,
appDBQuery
);** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Thanks, @arborRose. So the JSON format is not working for me. But your inline comment about making sure the page ID is in quotes did the trick.
const appDBQuery = `{ "content.ac_page_id": { "$eq": "${pageID}" } }`;
Although, I remember there were times that even this query was giving inconsistent results but I may try this out for now until I figure out how to make the JSON format work.
0
Categories
- All Categories
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 664 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 824 Beast Mode
- Visualize
- 2.6K Charting
- 86 App Studio
- 46 Variables
- Automate
- 194 Apps
- 486 APIs & Domo Developer
- 90 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 143 Governance & Security
- 11 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive