如何查询ScriptDB数据库中的键:嵌套在数组对象中的对象中的值Google Apps脚本

时间:2012-08-17 22:49:18

标签: google-apps-script javascript-objects

假设存储在ScriptDb中的对象 schema

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

我了解如何查询前两个属性但不知道如何运行查询以返回所有 interests[enthusiasm = moderate]

从字面上看这个例子并尝试:db.query({interests:[{enthusiasm: 'moderate'}]}); 返回 ScriptDbResult ,但任何尝试使用该结果的方法都会导致错误:

Queries can only contain letters, numbers, spaces, dashes and underscores as keys.

1 个答案:

答案 0 :(得分:2)

目前无法实现。它可能会在将来的更新中得到支持。你现在能做的最好的事情就是加载所有兴趣并自己循环遍历它们。