From 2fcb05a94e012ce08800bd6414b03cba339d76ec Mon Sep 17 00:00:00 2001 From: cardoso Date: Thu, 10 Aug 2017 09:27:43 -0300 Subject: [PATCH] Add Filter NodeConvertible conformance documentation --- 2.0/docs/fluent/query.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/2.0/docs/fluent/query.md b/2.0/docs/fluent/query.md index 21e4a6a3..8bb73b6d 100644 --- a/2.0/docs/fluent/query.md +++ b/2.0/docs/fluent/query.md @@ -165,6 +165,44 @@ Raw filters can be used to filter by values that should not be parameterized. try query.filter(raw: "date >= CURRENT_TIMESTAMP") ``` +### NodeConvertible Conformance + +Filters can be converted to and from Node objects, which allows filters to be specified via JSON and other NodeRepresentable formats. This makes it very easy if you want to allow a consumer API to filter your entities. + +Example: +```json +{ + "entity":"MyApp.User", + "method":{ + "type":"group", + "relation":"and", + "filters":[ + { + "entity":"MyApp.User", + "method":{ + "type":"compare", + "comparison":"greaterThanOrEquals", + "field":"age", + "value":18 + } + }, + { + "entity":"MyApp.User", + "method":{ + "type":"compare", + "comparison":"equals", + "field":"gender", + "value":"male" + } + } + ] + } +} +``` + +!!! note + You must include the module name in the entity field. "MyModule.MyEntity" + ## Distinct To select only distinct models from the database, add `.distinct()` to your query.