mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
add Clone methods for query builders (#10)
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/10 Closes T46957221 Reviewed By: idoshveki Differential Revision: D16278371 fbshipit-source-id: ca2b038fccb8fca6a7e8261444de27bdd63d0b00
This commit is contained in:
committed by
Facebook Github Bot
parent
b5cdb810b8
commit
dbe2afb946
@@ -249,6 +249,22 @@ func (bq *BoringQuery) ExistX(ctx context.Context) bool {
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (bq *BoringQuery) Clone() *BoringQuery {
|
||||
return &BoringQuery{
|
||||
config: bq.config,
|
||||
limit: bq.limit,
|
||||
offset: bq.offset,
|
||||
order: append([]Order{}, bq.order...),
|
||||
unique: append([]string{}, bq.unique...),
|
||||
predicates: append([]ent.Predicate{}, bq.predicates...),
|
||||
// clone intermediate queries.
|
||||
sql: bq.sql.Clone(),
|
||||
gremlin: bq.gremlin.Clone(),
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
func (bq *BoringQuery) GroupBy(field string, fields ...string) *BoringGroupBy {
|
||||
|
||||
Reference in New Issue
Block a user