files.com 1.2.123 → 1.2.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -0
- package/_VERSION +1 -1
- package/lib/Files.js +1 -1
- package/package.json +1 -1
- package/src/Files.js +1 -1
package/README.md
CHANGED
@@ -194,6 +194,113 @@ Files.configureNetwork({
|
|
194
194
|
})
|
195
195
|
```
|
196
196
|
|
197
|
+
## Sort and Filter
|
198
|
+
|
199
|
+
Several of the Files.com API resources have list operations that return multiple instances of the resource. The List operations
|
200
|
+
can be sorted and filtered.
|
201
|
+
|
202
|
+
### Sorting
|
203
|
+
|
204
|
+
The returned data can be sorted by passing in the ```sort_by``` method argument.
|
205
|
+
|
206
|
+
Each resource has a set of valid fields for sorting and can be sorted by one field at a time.
|
207
|
+
|
208
|
+
The argument value is a Javascript object that has a property of the resource field name sort on and a value of either ```"asc"``` or ```"desc"``` to specify the sort order.
|
209
|
+
|
210
|
+
### Filters
|
211
|
+
|
212
|
+
Filters apply selection criteria to the underlying query that returns the results. Filters can be applied individually to select resource fields
|
213
|
+
and/or in a combination with each other. The results of applying filters and filter combinations can be sorted by a single field.
|
214
|
+
|
215
|
+
The passed in argument value is a Javascript object that has a property of the resource field name to filter on and a passed in value to use in the filter comparison.
|
216
|
+
|
217
|
+
Each resource has their own set of valid filters and fields, valid combinations of filters, and sortable fields.
|
218
|
+
|
219
|
+
#### Types of Filters
|
220
|
+
|
221
|
+
##### Exact Filter
|
222
|
+
|
223
|
+
`filter` - find resources that have an exact field value match to a passed in value. (i.e., FIELD_VALUE = PASS_IN_VALUE).
|
224
|
+
|
225
|
+
#### Range Filters
|
226
|
+
|
227
|
+
`filter_gt` - find resources that have a field value that is greater than the passed in value. (i.e., FIELD_VALUE > PASS_IN_VALUE).
|
228
|
+
|
229
|
+
`filter_gte` - find resources that have a field value that is greater than or equal to the passed in value. (i.e., FIELD_VALUE >= PASS_IN_VALUE).
|
230
|
+
|
231
|
+
`filter_lt` - find resources that have a field value that is less than the passed in value. (i.e., FIELD_VALUE < PASS_IN_VALUE).
|
232
|
+
|
233
|
+
`filter_lte` - find resources that have a field value that is less than or equal to the passed in value. (i.e., FIELD_VALUE \<= PASS_IN_VALUE).
|
234
|
+
|
235
|
+
##### Pattern Filter
|
236
|
+
|
237
|
+
`filter_prefix` - find resources where the specified field is prefixed by the supplied value. This is applicable to values that are strings.
|
238
|
+
|
239
|
+
```javascript title="Sort Example"
|
240
|
+
// users sorted by username
|
241
|
+
Files.setApiKey('my-key');
|
242
|
+
var users = await User.list({
|
243
|
+
sort_by: { username: "asc"}
|
244
|
+
})
|
245
|
+
|
246
|
+
for (var i = 0; i < users.length; i++) {
|
247
|
+
console.log(users[i].username);
|
248
|
+
}
|
249
|
+
```
|
250
|
+
|
251
|
+
```javascript title="Exact Filter Example"
|
252
|
+
// non admin users
|
253
|
+
Files.setApiKey('my-key');
|
254
|
+
var users = await User.list({
|
255
|
+
filter: { not_site_admin: true },
|
256
|
+
sort_by: { username: "asc"}
|
257
|
+
})
|
258
|
+
|
259
|
+
for (var i = 0; i < users.length; i++) {
|
260
|
+
console.log(users[i].username);
|
261
|
+
}
|
262
|
+
```
|
263
|
+
|
264
|
+
```javascript title="Range Filter Example"
|
265
|
+
// users who haven't logged in since 2024-01-01
|
266
|
+
Files.setApiKey('my-key');
|
267
|
+
var users = await User.list({
|
268
|
+
filter_gte: { last_login_at: "2024-01-01" },
|
269
|
+
sort_by: { last_login_at: "asc"}
|
270
|
+
})
|
271
|
+
|
272
|
+
for (var i = 0; i < users.length; i++) {
|
273
|
+
console.log(users[i].username);
|
274
|
+
}
|
275
|
+
```
|
276
|
+
|
277
|
+
```javascript title="Pattern Filter Example"
|
278
|
+
// users who usernames start with 'test'
|
279
|
+
Files.setApiKey('my-key');
|
280
|
+
var users = await User.list({
|
281
|
+
filter_prefix: { username: "test" },
|
282
|
+
sort_by: { last_login_at: "asc"}
|
283
|
+
})
|
284
|
+
|
285
|
+
for (var i = 0; i < users.length; i++) {
|
286
|
+
console.log(users[i].username);
|
287
|
+
}
|
288
|
+
```
|
289
|
+
|
290
|
+
```javascript title="Combined Filter Example"
|
291
|
+
// users who usernames start with 'test' and are not admins
|
292
|
+
Files.setApiKey('my-key');
|
293
|
+
var users = await User.list({
|
294
|
+
filter_prefix: { username: "test" },
|
295
|
+
filter: { not_site_admin: true },
|
296
|
+
sort_by: { last_login_at: "asc"}
|
297
|
+
})
|
298
|
+
|
299
|
+
for (var i = 0; i < users.length; i++) {
|
300
|
+
console.log(users[i].username);
|
301
|
+
}
|
302
|
+
```
|
303
|
+
|
197
304
|
## Errors
|
198
305
|
|
199
306
|
The Files.com JavaScript SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond
|
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.124
|
package/lib/Files.js
CHANGED
@@ -11,7 +11,7 @@ var endpointPrefix = '/api/rest/v1';
|
|
11
11
|
var apiKey;
|
12
12
|
var baseUrl = 'https://app.files.com';
|
13
13
|
var sessionId = null;
|
14
|
-
var version = '1.2.
|
14
|
+
var version = '1.2.124';
|
15
15
|
var userAgent = "Files.com JavaScript SDK v".concat(version);
|
16
16
|
var logLevel = _Logger.LogLevel.INFO;
|
17
17
|
var debugRequest = false;
|
package/package.json
CHANGED
package/src/Files.js
CHANGED