loopback:不同的查询

Hee*_*hai 5 loopbackjs

我正在使用Loopback来创建Rest API.需要根据集合中的特定列获取不同的数据.我在下面尝试过,但它不起作用,而下面的代码片段也提取重复数据:

this.app.models.location.find(
                {
                    distinct: ("regionName",
                    {state: st})
                }
                ,
                function(err, location){........}
Run Code Online (Sandbox Code Playgroud)

'RegionName'是'location'集合的属性,我只需要选定状态的数据(state是location集合的另一个属性),由'st'表示.谢谢.

Hee*_*hai 0

Loopback框架还没有提供独特的功能。
使用distinct的Mongo db查询如下:

db.runCommand ( { distinct: "<collection>", key: "<field>", query: { <query>} })
Run Code Online (Sandbox Code Playgroud)

请参阅以下链接:
https ://docs.mongodb.org/manual/reference/command/distinct/