2017-11-05 1 views
0

からの結果を返さない:ループバック3.0:フィルターは、私はこのような、単一の単純なモデルで、ループバックAPI持ちのREST API

{ 
    "name": "Establishment", 
    "base": "PersistedModel", 
    "idInjection": true, 
    "options": { 
    "validateUpsert": true 
    }, 
    "properties": { 
    "Distance": { 
     "type": "number" 
    }, 
    "EstablishmentId": { 
     "type": "number" 
    }, 
    "EstablishmentType": { 
     "type": "string" 
    }, 
    "Location": { 
     "type": "string" 
    }, 
    "MinCost": { 
     "type": "number" 
    }, 
    "Name": { 
     "type": "string" 
    }, 
    "Stars": { 
     "type": "number" 
    }, 
    "UserRating": { 
     "type": "number" 
    }, 
    "UserRatingTitle": { 
     "type": "string" 
    }, 
    "UserRatingCount": { 
     "type": "number" 
    }, 
    "ImageUrl": { 
     "type": "string" 
    }, 
    "ThumbnailUrl": { 
     "type": "string" 
    } 
    }, 
    "validations": [], 
    "relations": {}, 
    "acls": [], 
    "methods": {} 
} 

予想通りの結果のhttp://localhost:3000/api/Establishmentsリターンすべて、シンプルに電話を。 http://localhost:3000/api/Establishments?filter[where][distance][gt]=30を呼び出すと結果はまったく得られません。空の配列です。

Establishmentがたくさんあり、Distanceが30を超えています。他のプロパティで実際にフィルタを使用すると、空の配列になります。私は何が欠けていますか?

+0

多分距離」の大文字と小文字が区別試みは、最初の文字を小文字またはちょうど使用するようにモデルにあなたのフィールドの名前を変更するので、 "あなたのフィルタで –

答えて

0

私がコメントで述べたように、大文字と小文字が区別され、私はそれを確実にするために私のアプリでそれを変更しました。

それは次のようになります。

http://localhost:3000/api/Establishments?filter[where][Distance][gt]=30 

か、この形式で試すことができます。

http://localhost:3000/api/Establishments?filter={"where":{"Distance":{"gt":30}}} 
+0

私はインプレッションURLの下にあった大文字と小文字を区別しません。いずれにせよ、最初の提案は機能せず、2番目の提案はまだ距離が30未満の施設を返します。 – serlingpa

+0

@serlingpaこのスコープをestablish.json '" scope "に追加してください:{ " where:{ "距離":{"gt":30} } } 'これをhttp:// localhost:3000/api/Establishmentsと呼びます。 –

関連する問題