Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query a ScriptDB database for key:values within objects nested in array objects Google Apps Script

Assume an object schema stored in ScriptDb:

{name: 'alice',
 age:  12,
 interests: [
     {interest: 'tea parties', enthusiasm: 'high'},
     {interest: 'croquet', enthusiasm: 'moderate'},         
 ]
}

I understand how to query against the first two attributes but not how to run a query to return all rows where interests[enthusiasm = moderate]

Taking that example literally and trying: db.query({interests:[{enthusiasm: 'moderate'}]}); returns a ScriptDbResult but any attempt to use that result's methods results in an error:

Queries can only contain letters, numbers, spaces, dashes and underscores as keys.
like image 948
JSDBroughton Avatar asked Apr 30 '26 21:04

JSDBroughton


1 Answers

This is not currently possible. It may be supported in a future update. The best you can do now is load all interests and loop through them yourself.

like image 167
Corey G Avatar answered May 03 '26 11:05

Corey G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!