1
私は、リモートの方法で検索で簡単な発注フィルタで苦労しています:ループバックオーダーフィルタモデルからリモートメソッドで検索を使用して、エラー:
/**
* This remote method exposes the meals history from the current logged in user
*/
Meal.listMeals = function(req, res, cb) {
Meal.find({
where: {patientId: req.accessToken.userId},
order: {mealDate: 'DESC'}
}, cb);
};
Meal.remoteMethod('listMeals', {
returns: {arg: 'meals', type: 'array'},
http: {path:'/list-meals', verb: 'get'},
accepts: [
{arg: 'req', type: 'object', http: {source: 'req'}},
{arg: 'res', type: 'object', http: {source: 'res'}}
]
});
あなたの上には、私のリモートを参照してください私はエラーを取得する:/かつて私はオーデル{「DESC」mealDate}:ことを追加します..それは次フィルタなしで正常に動作し、実装を見つける
The order {"mealDate":"DESC"} is not valid
mealDateは私のモデルにDate型です。
"properties": {
"mealDate": {
"type": "date",
"required": true,
"default": "Date.now"
},
何か問題がありますか?
P.S - 私はこれを行うために配列内でソートダイレクトを使うことができますが、この場合はループバックフィルターを使用しようとしていますが、私はしばらくの間固執しています。 docに基づいて
。 –