https://strapi.io/documentation/developer-docs/latest/developer-resources/content-api/content-api.html#limit
过滤器
Filter | Description |
---|---|
No suffix or eq |
Equal |
ne |
Not equal |
lt |
Less than |
gt |
Greater than |
lte |
Less than or equal to |
gte |
Greater than or equal to |
in |
Included in an array |
nin |
Not included in an array |
contains |
Contains |
ncontains |
Doesn't contain |
containss |
Contains, case sensitive |
ncontainss |
Doesn't contain, case sensitive |
null |
Is null or not null |
查询
GET /users?firstName=John` or `GET /users?firstName_eq=John
GET /restaurants?price_gte=3
GET /restaurants?id_in=3&id_in=6&id_in=8
GET /restaurants?_where[price_gte]=3
GET /restaurants?_where[0][price_gte]=3&[0][price_lte]=7
AND
const query = qs.stringify({
_where: [{ stars: 1 }, { pricing_lte: 20 }],
});
await request(`/restaurants?${query}`);
// GET /restaurants?_where[0][stars]=1&_where[1][pricing_lte]=20
OR
const query = qs.stringify({ _where: { _or: [{ stars: 1 }, { pricing_gt: 30 }] } });
await request(`/restaurant?${query}`);
// GET /restaurants?_where[_or][0][stars]=1&_where[_or][1][pricing_gt]=30
// -----------------
const query = qs.stringify({ _where: { stars: [1, 2] } });
await request(`/restaurant?${query}`);
// GET /restaurants?_where[stars][0]=1&_where[stars][1]=2
COMBO
const query = qs.stringify({
_where: {
_or: [
[{ stars: 2 }, { pricing_lt: 80 }], // implicit AND
[{ stars: 1 }, { pricing_gte: 50 }], // implicit AND
],
},
});
await request(`/restaurants?${query}`);
// GET /restaurants?_where[_or][0][0][stars]=2&_where[_or][0][1][pricing_lt]=80&_where[_or][1][0][stars]=1&_where[_or][1][1][pricing_gte]=50
const query = qs.stringify({
_where: {
_or: [
[{ stars: 2 }, { pricing_lt: 80 }], // implicit AND
[{ stars: 1 }, { 'categories.name': 'French' }], // implicit AND
],
},
});
await request(`/restaurants?${query}`);
// GET /restaurants?_where[_or][0][0][stars]=2&_where[_or][0][1][pricing_lt]=80&_where[_or][1][0][stars]=1&_where[_or][1][1][categories.name]=French
GET /restaurants?chef.restaurant.star=5
SORT
Sort users by email.
- ASC:
GET /users?_sort=email:ASC
- DESC:
GET /users?_sort=email:DESC
Sorting on multiple fields
GET /users?_sort=email:asc,dateField:desc
GET /users?_sort=email:DESC,username:ASC
LIMIT
GET /users?_limit=30
START
GET /users?_start=10&_limit=10
Publish State
Get published articles
GET /articles` OR `GET /articles?_publicationState=live
Get both published and draft articles
GET /articles?_publicationState=preview
NOTE
If you only want to retrieve your draft entries, you can combine the preview
mode and the published_at
field. GET /articles?_publicationState=preview&published_at_null=true
Comments(0)