@@ -14,7 +14,7 @@ pip install nocodb
1414### Client configuration
1515``` python
1616from nocodb.nocodb import NocoDBProject, APIToken, JWTAuthToken
17- from nocodb.filters import InFilter , EqFilter
17+ from nocodb.filters import LikeFilter , EqFilter
1818from nocodb.infra.requests_client import NocoDBRequestsClient
1919
2020
@@ -98,7 +98,7 @@ table_rows = client.table_row_list(project, table_name, params={'offset': 100})
9898# Filter the query
9999# Currently only one filter at a time is allowed. I don't know how to join
100100# multiple conditions in nocodb dsl. If you know how please let me know :).
101- table_rows = client.table_row_list(project, table_name, InFilter (" name" , " sam" ))
101+ table_rows = client.table_row_list(project, table_name, LikeFilter (" name" , " % s am% " ))
102102table_rows = client.table_row_list(project, table_name, filter_obj = EqFilter(" Id" , 100 ))
103103
104104# Filter and count rows
@@ -114,22 +114,79 @@ row = client.table_row_detail(project, table_name, row_id)
114114# Create a new row
115115row_info = {
116116 " name" : " my thoughts" ,
117- " content" : " i'm going to buy samuel a beer because i love this module" ,
117+ " content" : " i'm going to buy samuel a beer 🍻 because I 💚 this module" ,
118118 " mood" : " :)"
119119}
120120client.table_row_create(project, table_name, row_info)
121121
122122# Update a row
123123row_id = 2
124124row_info = {
125- " content" : " i'm going to buy samuel a new car because i love this module" ,
125+ " content" : " i'm going to buy samuel a new car 🚙 because I 💚 this module" ,
126126}
127127client.table_row_update(project, table_name, row_id, row_info)
128128
129129# Delete a row (only if you've already bought me a beer)
130130client.table_row_delete(project, table_name, row_id)
131131```
132132
133+ ### Available filters
134+
135+ - EqFilter
136+ - EqualFilter (Alias of EqFilter)
137+ - NotEqualFilter
138+ - GreaterThanFilter
139+ - GreaterOrEqualFilter
140+ - LessThanFilter
141+ - LessOrEqualFilter
142+ - LikeFilter
143+
144+ ### Using custom filters
145+
146+ Nocodb is evolving and new operators are comming with each release.
147+
148+ Most of the basic operations are inside this package but you could need some new
149+ feature that could not be added yet.
150+ For those filters you can build your own.
151+
152+ Example for basic filters:
153+
154+ ``` python
155+ from nocodb.filters.factory import basic_filter_class_factory
156+
157+ BasicFilter = basic_filter_class_factory(' =' )
158+ table_rows = client.table_row_list(project, table_name, BasicFilter(' age' , ' 16' ))
159+
160+ ```
161+
162+ You can find the updated list of all the available nocodb operators [ here] ( https://docs.nocodb.com/developer-resources/rest-apis/#comparison-operators ) .
163+
164+ In some cases you might want to write your own filter string as described in the previous link.
165+ For that cases you can use the less-semmantic RawFilter.
166+
167+ ``` python
168+ from nocodb.filters.raw_filter import RawFilter
169+
170+ table_rows = client.table_row_list(project, table_name, RawFilter(' (birthday,eq,exactDate,2023-06-01)' ))
171+ ```
172+
173+ In some cases we might want to have a file with some custom raw filters already defined by us.
174+ We can easily create custom raw filter classes using ` raw_template_filter_class_factory ` .
175+
176+ ``` python
177+ from nocodb.filters.factory import raw_template_filter_class_factory
178+
179+ BirthdayDateFilter = raw_template_filter_class_factory(' (birthday,eq,exactDate,{} )' )
180+ ExactDateEqFilter = raw_template_filter_class_factory(' ({} ,eq,exactDate,{} )' )
181+ ExactDateOpFilter = raw_template_filter_class_factory(' ({} ,{op} ,exactDate,{} )' )
182+
183+ table_rows = client.table_row_list(project, table_name, BirthdayDateFilter(' 2023-06-01' ))
184+ table_rows = client.table_row_list(project, table_name, ExactDateEqFilter(' column' , ' 2023-06-01' ))
185+ table_rows = client.table_row_list(project, table_name, ExactDateOpFilter(' column' , ' 2023-06-01' , op = ' eq' ))
186+ ```
187+
188+ Credits to @MitPitt for asking this feature.
189+
133190## Author notes
134191
135192I created this package to bootstrap some personal projects and I hope it
0 commit comments