ent 基本使用十八 查询谓词
ent 生成的代码包含了比较完整的查询谓词
字段谓词
- Bool:
- =, !=
- Numeric:
- =, !=, >, <, >=, <=,
- IN, NOT IN
- Time:
- =, !=, >, <, >=, <=
- IN, NOT IN
- String:
- =, !=, >, <, >=, <=
- IN, NOT IN
- Contains, HasPrefix, HasSuffix
- ContainsFold, EqualFold (SQL specific)
- Optional fields:
- IsNil, NotNil
edge 谓词
- HasEdge
client.Pet.
Query().
Where(user.HasOwner()).
All(ctx)
- HasEdgeWith
client.Pet.
Query().
Where(user.HasOwnerWith(user.Name("a8m"))).
All(ctx)
Not
client.Pet.
Query().
Where(user.Not(user.NameHasPrefix("Ari"))).
All(ctx)
OR
client.Pet.
Query().
Where(
user.Or(
user.HasOwner(),
user.Not(user.HasFriends()),
)
).
All(ctx)
AND
client.Pet.
Query().
Where(
user.And(
user.HasOwner(),
user.Not(user.HasFriends()),
)
).
All(ctx)