client.go 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "log"
  8. "reflect"
  9. "wechat-api/ent/migrate"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/batchmsg"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/employee"
  14. "wechat-api/ent/label"
  15. "wechat-api/ent/labelrelationship"
  16. "wechat-api/ent/message"
  17. "wechat-api/ent/messagerecords"
  18. "wechat-api/ent/msg"
  19. "wechat-api/ent/server"
  20. "wechat-api/ent/sopnode"
  21. "wechat-api/ent/sopstage"
  22. "wechat-api/ent/soptask"
  23. "wechat-api/ent/tutorial"
  24. "wechat-api/ent/workexperience"
  25. "wechat-api/ent/wx"
  26. "entgo.io/ent"
  27. "entgo.io/ent/dialect"
  28. "entgo.io/ent/dialect/sql"
  29. "entgo.io/ent/dialect/sql/sqlgraph"
  30. stdsql "database/sql"
  31. )
  32. // Client is the client that holds all ent builders.
  33. type Client struct {
  34. config
  35. // Schema is the client for creating, migrating and dropping schema.
  36. Schema *migrate.Schema
  37. // Agent is the client for interacting with the Agent builders.
  38. Agent *AgentClient
  39. // BatchMsg is the client for interacting with the BatchMsg builders.
  40. BatchMsg *BatchMsgClient
  41. // Contact is the client for interacting with the Contact builders.
  42. Contact *ContactClient
  43. // Employee is the client for interacting with the Employee builders.
  44. Employee *EmployeeClient
  45. // Label is the client for interacting with the Label builders.
  46. Label *LabelClient
  47. // LabelRelationship is the client for interacting with the LabelRelationship builders.
  48. LabelRelationship *LabelRelationshipClient
  49. // Message is the client for interacting with the Message builders.
  50. Message *MessageClient
  51. // MessageRecords is the client for interacting with the MessageRecords builders.
  52. MessageRecords *MessageRecordsClient
  53. // Msg is the client for interacting with the Msg builders.
  54. Msg *MsgClient
  55. // Server is the client for interacting with the Server builders.
  56. Server *ServerClient
  57. // SopNode is the client for interacting with the SopNode builders.
  58. SopNode *SopNodeClient
  59. // SopStage is the client for interacting with the SopStage builders.
  60. SopStage *SopStageClient
  61. // SopTask is the client for interacting with the SopTask builders.
  62. SopTask *SopTaskClient
  63. // Tutorial is the client for interacting with the Tutorial builders.
  64. Tutorial *TutorialClient
  65. // WorkExperience is the client for interacting with the WorkExperience builders.
  66. WorkExperience *WorkExperienceClient
  67. // Wx is the client for interacting with the Wx builders.
  68. Wx *WxClient
  69. }
  70. // NewClient creates a new client configured with the given options.
  71. func NewClient(opts ...Option) *Client {
  72. client := &Client{config: newConfig(opts...)}
  73. client.init()
  74. return client
  75. }
  76. func (c *Client) init() {
  77. c.Schema = migrate.NewSchema(c.driver)
  78. c.Agent = NewAgentClient(c.config)
  79. c.BatchMsg = NewBatchMsgClient(c.config)
  80. c.Contact = NewContactClient(c.config)
  81. c.Employee = NewEmployeeClient(c.config)
  82. c.Label = NewLabelClient(c.config)
  83. c.LabelRelationship = NewLabelRelationshipClient(c.config)
  84. c.Message = NewMessageClient(c.config)
  85. c.MessageRecords = NewMessageRecordsClient(c.config)
  86. c.Msg = NewMsgClient(c.config)
  87. c.Server = NewServerClient(c.config)
  88. c.SopNode = NewSopNodeClient(c.config)
  89. c.SopStage = NewSopStageClient(c.config)
  90. c.SopTask = NewSopTaskClient(c.config)
  91. c.Tutorial = NewTutorialClient(c.config)
  92. c.WorkExperience = NewWorkExperienceClient(c.config)
  93. c.Wx = NewWxClient(c.config)
  94. }
  95. type (
  96. // config is the configuration for the client and its builder.
  97. config struct {
  98. // driver used for executing database requests.
  99. driver dialect.Driver
  100. // debug enable a debug logging.
  101. debug bool
  102. // log used for logging on debug mode.
  103. log func(...any)
  104. // hooks to execute on mutations.
  105. hooks *hooks
  106. // interceptors to execute on queries.
  107. inters *inters
  108. }
  109. // Option function to configure the client.
  110. Option func(*config)
  111. )
  112. // newConfig creates a new config for the client.
  113. func newConfig(opts ...Option) config {
  114. cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
  115. cfg.options(opts...)
  116. return cfg
  117. }
  118. // options applies the options on the config object.
  119. func (c *config) options(opts ...Option) {
  120. for _, opt := range opts {
  121. opt(c)
  122. }
  123. if c.debug {
  124. c.driver = dialect.Debug(c.driver, c.log)
  125. }
  126. }
  127. // Debug enables debug logging on the ent.Driver.
  128. func Debug() Option {
  129. return func(c *config) {
  130. c.debug = true
  131. }
  132. }
  133. // Log sets the logging function for debug mode.
  134. func Log(fn func(...any)) Option {
  135. return func(c *config) {
  136. c.log = fn
  137. }
  138. }
  139. // Driver configures the client driver.
  140. func Driver(driver dialect.Driver) Option {
  141. return func(c *config) {
  142. c.driver = driver
  143. }
  144. }
  145. // Open opens a database/sql.DB specified by the driver name and
  146. // the data source name, and returns a new client attached to it.
  147. // Optional parameters can be added for configuring the client.
  148. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
  149. switch driverName {
  150. case dialect.MySQL, dialect.Postgres, dialect.SQLite:
  151. drv, err := sql.Open(driverName, dataSourceName)
  152. if err != nil {
  153. return nil, err
  154. }
  155. return NewClient(append(options, Driver(drv))...), nil
  156. default:
  157. return nil, fmt.Errorf("unsupported driver: %q", driverName)
  158. }
  159. }
  160. // ErrTxStarted is returned when trying to start a new transaction from a transactional client.
  161. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
  162. // Tx returns a new transactional client. The provided context
  163. // is used until the transaction is committed or rolled back.
  164. func (c *Client) Tx(ctx context.Context) (*Tx, error) {
  165. if _, ok := c.driver.(*txDriver); ok {
  166. return nil, ErrTxStarted
  167. }
  168. tx, err := newTx(ctx, c.driver)
  169. if err != nil {
  170. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  171. }
  172. cfg := c.config
  173. cfg.driver = tx
  174. return &Tx{
  175. ctx: ctx,
  176. config: cfg,
  177. Agent: NewAgentClient(cfg),
  178. BatchMsg: NewBatchMsgClient(cfg),
  179. Contact: NewContactClient(cfg),
  180. Employee: NewEmployeeClient(cfg),
  181. Label: NewLabelClient(cfg),
  182. LabelRelationship: NewLabelRelationshipClient(cfg),
  183. Message: NewMessageClient(cfg),
  184. MessageRecords: NewMessageRecordsClient(cfg),
  185. Msg: NewMsgClient(cfg),
  186. Server: NewServerClient(cfg),
  187. SopNode: NewSopNodeClient(cfg),
  188. SopStage: NewSopStageClient(cfg),
  189. SopTask: NewSopTaskClient(cfg),
  190. Tutorial: NewTutorialClient(cfg),
  191. WorkExperience: NewWorkExperienceClient(cfg),
  192. Wx: NewWxClient(cfg),
  193. }, nil
  194. }
  195. // BeginTx returns a transactional client with specified options.
  196. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
  197. if _, ok := c.driver.(*txDriver); ok {
  198. return nil, errors.New("ent: cannot start a transaction within a transaction")
  199. }
  200. tx, err := c.driver.(interface {
  201. BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
  202. }).BeginTx(ctx, opts)
  203. if err != nil {
  204. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  205. }
  206. cfg := c.config
  207. cfg.driver = &txDriver{tx: tx, drv: c.driver}
  208. return &Tx{
  209. ctx: ctx,
  210. config: cfg,
  211. Agent: NewAgentClient(cfg),
  212. BatchMsg: NewBatchMsgClient(cfg),
  213. Contact: NewContactClient(cfg),
  214. Employee: NewEmployeeClient(cfg),
  215. Label: NewLabelClient(cfg),
  216. LabelRelationship: NewLabelRelationshipClient(cfg),
  217. Message: NewMessageClient(cfg),
  218. MessageRecords: NewMessageRecordsClient(cfg),
  219. Msg: NewMsgClient(cfg),
  220. Server: NewServerClient(cfg),
  221. SopNode: NewSopNodeClient(cfg),
  222. SopStage: NewSopStageClient(cfg),
  223. SopTask: NewSopTaskClient(cfg),
  224. Tutorial: NewTutorialClient(cfg),
  225. WorkExperience: NewWorkExperienceClient(cfg),
  226. Wx: NewWxClient(cfg),
  227. }, nil
  228. }
  229. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
  230. //
  231. // client.Debug().
  232. // Agent.
  233. // Query().
  234. // Count(ctx)
  235. func (c *Client) Debug() *Client {
  236. if c.debug {
  237. return c
  238. }
  239. cfg := c.config
  240. cfg.driver = dialect.Debug(c.driver, c.log)
  241. client := &Client{config: cfg}
  242. client.init()
  243. return client
  244. }
  245. // Close closes the database connection and prevents new queries from starting.
  246. func (c *Client) Close() error {
  247. return c.driver.Close()
  248. }
  249. // Use adds the mutation hooks to all the entity clients.
  250. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
  251. func (c *Client) Use(hooks ...Hook) {
  252. for _, n := range []interface{ Use(...Hook) }{
  253. c.Agent, c.BatchMsg, c.Contact, c.Employee, c.Label, c.LabelRelationship,
  254. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  255. c.Tutorial, c.WorkExperience, c.Wx,
  256. } {
  257. n.Use(hooks...)
  258. }
  259. }
  260. // Intercept adds the query interceptors to all the entity clients.
  261. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
  262. func (c *Client) Intercept(interceptors ...Interceptor) {
  263. for _, n := range []interface{ Intercept(...Interceptor) }{
  264. c.Agent, c.BatchMsg, c.Contact, c.Employee, c.Label, c.LabelRelationship,
  265. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  266. c.Tutorial, c.WorkExperience, c.Wx,
  267. } {
  268. n.Intercept(interceptors...)
  269. }
  270. }
  271. // Mutate implements the ent.Mutator interface.
  272. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
  273. switch m := m.(type) {
  274. case *AgentMutation:
  275. return c.Agent.mutate(ctx, m)
  276. case *BatchMsgMutation:
  277. return c.BatchMsg.mutate(ctx, m)
  278. case *ContactMutation:
  279. return c.Contact.mutate(ctx, m)
  280. case *EmployeeMutation:
  281. return c.Employee.mutate(ctx, m)
  282. case *LabelMutation:
  283. return c.Label.mutate(ctx, m)
  284. case *LabelRelationshipMutation:
  285. return c.LabelRelationship.mutate(ctx, m)
  286. case *MessageMutation:
  287. return c.Message.mutate(ctx, m)
  288. case *MessageRecordsMutation:
  289. return c.MessageRecords.mutate(ctx, m)
  290. case *MsgMutation:
  291. return c.Msg.mutate(ctx, m)
  292. case *ServerMutation:
  293. return c.Server.mutate(ctx, m)
  294. case *SopNodeMutation:
  295. return c.SopNode.mutate(ctx, m)
  296. case *SopStageMutation:
  297. return c.SopStage.mutate(ctx, m)
  298. case *SopTaskMutation:
  299. return c.SopTask.mutate(ctx, m)
  300. case *TutorialMutation:
  301. return c.Tutorial.mutate(ctx, m)
  302. case *WorkExperienceMutation:
  303. return c.WorkExperience.mutate(ctx, m)
  304. case *WxMutation:
  305. return c.Wx.mutate(ctx, m)
  306. default:
  307. return nil, fmt.Errorf("ent: unknown mutation type %T", m)
  308. }
  309. }
  310. // AgentClient is a client for the Agent schema.
  311. type AgentClient struct {
  312. config
  313. }
  314. // NewAgentClient returns a client for the Agent from the given config.
  315. func NewAgentClient(c config) *AgentClient {
  316. return &AgentClient{config: c}
  317. }
  318. // Use adds a list of mutation hooks to the hooks stack.
  319. // A call to `Use(f, g, h)` equals to `agent.Hooks(f(g(h())))`.
  320. func (c *AgentClient) Use(hooks ...Hook) {
  321. c.hooks.Agent = append(c.hooks.Agent, hooks...)
  322. }
  323. // Intercept adds a list of query interceptors to the interceptors stack.
  324. // A call to `Intercept(f, g, h)` equals to `agent.Intercept(f(g(h())))`.
  325. func (c *AgentClient) Intercept(interceptors ...Interceptor) {
  326. c.inters.Agent = append(c.inters.Agent, interceptors...)
  327. }
  328. // Create returns a builder for creating a Agent entity.
  329. func (c *AgentClient) Create() *AgentCreate {
  330. mutation := newAgentMutation(c.config, OpCreate)
  331. return &AgentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  332. }
  333. // CreateBulk returns a builder for creating a bulk of Agent entities.
  334. func (c *AgentClient) CreateBulk(builders ...*AgentCreate) *AgentCreateBulk {
  335. return &AgentCreateBulk{config: c.config, builders: builders}
  336. }
  337. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  338. // a builder and applies setFunc on it.
  339. func (c *AgentClient) MapCreateBulk(slice any, setFunc func(*AgentCreate, int)) *AgentCreateBulk {
  340. rv := reflect.ValueOf(slice)
  341. if rv.Kind() != reflect.Slice {
  342. return &AgentCreateBulk{err: fmt.Errorf("calling to AgentClient.MapCreateBulk with wrong type %T, need slice", slice)}
  343. }
  344. builders := make([]*AgentCreate, rv.Len())
  345. for i := 0; i < rv.Len(); i++ {
  346. builders[i] = c.Create()
  347. setFunc(builders[i], i)
  348. }
  349. return &AgentCreateBulk{config: c.config, builders: builders}
  350. }
  351. // Update returns an update builder for Agent.
  352. func (c *AgentClient) Update() *AgentUpdate {
  353. mutation := newAgentMutation(c.config, OpUpdate)
  354. return &AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  355. }
  356. // UpdateOne returns an update builder for the given entity.
  357. func (c *AgentClient) UpdateOne(a *Agent) *AgentUpdateOne {
  358. mutation := newAgentMutation(c.config, OpUpdateOne, withAgent(a))
  359. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  360. }
  361. // UpdateOneID returns an update builder for the given id.
  362. func (c *AgentClient) UpdateOneID(id uint64) *AgentUpdateOne {
  363. mutation := newAgentMutation(c.config, OpUpdateOne, withAgentID(id))
  364. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  365. }
  366. // Delete returns a delete builder for Agent.
  367. func (c *AgentClient) Delete() *AgentDelete {
  368. mutation := newAgentMutation(c.config, OpDelete)
  369. return &AgentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  370. }
  371. // DeleteOne returns a builder for deleting the given entity.
  372. func (c *AgentClient) DeleteOne(a *Agent) *AgentDeleteOne {
  373. return c.DeleteOneID(a.ID)
  374. }
  375. // DeleteOneID returns a builder for deleting the given entity by its id.
  376. func (c *AgentClient) DeleteOneID(id uint64) *AgentDeleteOne {
  377. builder := c.Delete().Where(agent.ID(id))
  378. builder.mutation.id = &id
  379. builder.mutation.op = OpDeleteOne
  380. return &AgentDeleteOne{builder}
  381. }
  382. // Query returns a query builder for Agent.
  383. func (c *AgentClient) Query() *AgentQuery {
  384. return &AgentQuery{
  385. config: c.config,
  386. ctx: &QueryContext{Type: TypeAgent},
  387. inters: c.Interceptors(),
  388. }
  389. }
  390. // Get returns a Agent entity by its id.
  391. func (c *AgentClient) Get(ctx context.Context, id uint64) (*Agent, error) {
  392. return c.Query().Where(agent.ID(id)).Only(ctx)
  393. }
  394. // GetX is like Get, but panics if an error occurs.
  395. func (c *AgentClient) GetX(ctx context.Context, id uint64) *Agent {
  396. obj, err := c.Get(ctx, id)
  397. if err != nil {
  398. panic(err)
  399. }
  400. return obj
  401. }
  402. // QueryWxAgent queries the wx_agent edge of a Agent.
  403. func (c *AgentClient) QueryWxAgent(a *Agent) *WxQuery {
  404. query := (&WxClient{config: c.config}).Query()
  405. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  406. id := a.ID
  407. step := sqlgraph.NewStep(
  408. sqlgraph.From(agent.Table, agent.FieldID, id),
  409. sqlgraph.To(wx.Table, wx.FieldID),
  410. sqlgraph.Edge(sqlgraph.O2M, false, agent.WxAgentTable, agent.WxAgentColumn),
  411. )
  412. fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
  413. return fromV, nil
  414. }
  415. return query
  416. }
  417. // Hooks returns the client hooks.
  418. func (c *AgentClient) Hooks() []Hook {
  419. hooks := c.hooks.Agent
  420. return append(hooks[:len(hooks):len(hooks)], agent.Hooks[:]...)
  421. }
  422. // Interceptors returns the client interceptors.
  423. func (c *AgentClient) Interceptors() []Interceptor {
  424. inters := c.inters.Agent
  425. return append(inters[:len(inters):len(inters)], agent.Interceptors[:]...)
  426. }
  427. func (c *AgentClient) mutate(ctx context.Context, m *AgentMutation) (Value, error) {
  428. switch m.Op() {
  429. case OpCreate:
  430. return (&AgentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  431. case OpUpdate:
  432. return (&AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  433. case OpUpdateOne:
  434. return (&AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  435. case OpDelete, OpDeleteOne:
  436. return (&AgentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  437. default:
  438. return nil, fmt.Errorf("ent: unknown Agent mutation op: %q", m.Op())
  439. }
  440. }
  441. // BatchMsgClient is a client for the BatchMsg schema.
  442. type BatchMsgClient struct {
  443. config
  444. }
  445. // NewBatchMsgClient returns a client for the BatchMsg from the given config.
  446. func NewBatchMsgClient(c config) *BatchMsgClient {
  447. return &BatchMsgClient{config: c}
  448. }
  449. // Use adds a list of mutation hooks to the hooks stack.
  450. // A call to `Use(f, g, h)` equals to `batchmsg.Hooks(f(g(h())))`.
  451. func (c *BatchMsgClient) Use(hooks ...Hook) {
  452. c.hooks.BatchMsg = append(c.hooks.BatchMsg, hooks...)
  453. }
  454. // Intercept adds a list of query interceptors to the interceptors stack.
  455. // A call to `Intercept(f, g, h)` equals to `batchmsg.Intercept(f(g(h())))`.
  456. func (c *BatchMsgClient) Intercept(interceptors ...Interceptor) {
  457. c.inters.BatchMsg = append(c.inters.BatchMsg, interceptors...)
  458. }
  459. // Create returns a builder for creating a BatchMsg entity.
  460. func (c *BatchMsgClient) Create() *BatchMsgCreate {
  461. mutation := newBatchMsgMutation(c.config, OpCreate)
  462. return &BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  463. }
  464. // CreateBulk returns a builder for creating a bulk of BatchMsg entities.
  465. func (c *BatchMsgClient) CreateBulk(builders ...*BatchMsgCreate) *BatchMsgCreateBulk {
  466. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  467. }
  468. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  469. // a builder and applies setFunc on it.
  470. func (c *BatchMsgClient) MapCreateBulk(slice any, setFunc func(*BatchMsgCreate, int)) *BatchMsgCreateBulk {
  471. rv := reflect.ValueOf(slice)
  472. if rv.Kind() != reflect.Slice {
  473. return &BatchMsgCreateBulk{err: fmt.Errorf("calling to BatchMsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  474. }
  475. builders := make([]*BatchMsgCreate, rv.Len())
  476. for i := 0; i < rv.Len(); i++ {
  477. builders[i] = c.Create()
  478. setFunc(builders[i], i)
  479. }
  480. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  481. }
  482. // Update returns an update builder for BatchMsg.
  483. func (c *BatchMsgClient) Update() *BatchMsgUpdate {
  484. mutation := newBatchMsgMutation(c.config, OpUpdate)
  485. return &BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  486. }
  487. // UpdateOne returns an update builder for the given entity.
  488. func (c *BatchMsgClient) UpdateOne(bm *BatchMsg) *BatchMsgUpdateOne {
  489. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsg(bm))
  490. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  491. }
  492. // UpdateOneID returns an update builder for the given id.
  493. func (c *BatchMsgClient) UpdateOneID(id uint64) *BatchMsgUpdateOne {
  494. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsgID(id))
  495. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  496. }
  497. // Delete returns a delete builder for BatchMsg.
  498. func (c *BatchMsgClient) Delete() *BatchMsgDelete {
  499. mutation := newBatchMsgMutation(c.config, OpDelete)
  500. return &BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  501. }
  502. // DeleteOne returns a builder for deleting the given entity.
  503. func (c *BatchMsgClient) DeleteOne(bm *BatchMsg) *BatchMsgDeleteOne {
  504. return c.DeleteOneID(bm.ID)
  505. }
  506. // DeleteOneID returns a builder for deleting the given entity by its id.
  507. func (c *BatchMsgClient) DeleteOneID(id uint64) *BatchMsgDeleteOne {
  508. builder := c.Delete().Where(batchmsg.ID(id))
  509. builder.mutation.id = &id
  510. builder.mutation.op = OpDeleteOne
  511. return &BatchMsgDeleteOne{builder}
  512. }
  513. // Query returns a query builder for BatchMsg.
  514. func (c *BatchMsgClient) Query() *BatchMsgQuery {
  515. return &BatchMsgQuery{
  516. config: c.config,
  517. ctx: &QueryContext{Type: TypeBatchMsg},
  518. inters: c.Interceptors(),
  519. }
  520. }
  521. // Get returns a BatchMsg entity by its id.
  522. func (c *BatchMsgClient) Get(ctx context.Context, id uint64) (*BatchMsg, error) {
  523. return c.Query().Where(batchmsg.ID(id)).Only(ctx)
  524. }
  525. // GetX is like Get, but panics if an error occurs.
  526. func (c *BatchMsgClient) GetX(ctx context.Context, id uint64) *BatchMsg {
  527. obj, err := c.Get(ctx, id)
  528. if err != nil {
  529. panic(err)
  530. }
  531. return obj
  532. }
  533. // Hooks returns the client hooks.
  534. func (c *BatchMsgClient) Hooks() []Hook {
  535. hooks := c.hooks.BatchMsg
  536. return append(hooks[:len(hooks):len(hooks)], batchmsg.Hooks[:]...)
  537. }
  538. // Interceptors returns the client interceptors.
  539. func (c *BatchMsgClient) Interceptors() []Interceptor {
  540. inters := c.inters.BatchMsg
  541. return append(inters[:len(inters):len(inters)], batchmsg.Interceptors[:]...)
  542. }
  543. func (c *BatchMsgClient) mutate(ctx context.Context, m *BatchMsgMutation) (Value, error) {
  544. switch m.Op() {
  545. case OpCreate:
  546. return (&BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  547. case OpUpdate:
  548. return (&BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  549. case OpUpdateOne:
  550. return (&BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  551. case OpDelete, OpDeleteOne:
  552. return (&BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  553. default:
  554. return nil, fmt.Errorf("ent: unknown BatchMsg mutation op: %q", m.Op())
  555. }
  556. }
  557. // ContactClient is a client for the Contact schema.
  558. type ContactClient struct {
  559. config
  560. }
  561. // NewContactClient returns a client for the Contact from the given config.
  562. func NewContactClient(c config) *ContactClient {
  563. return &ContactClient{config: c}
  564. }
  565. // Use adds a list of mutation hooks to the hooks stack.
  566. // A call to `Use(f, g, h)` equals to `contact.Hooks(f(g(h())))`.
  567. func (c *ContactClient) Use(hooks ...Hook) {
  568. c.hooks.Contact = append(c.hooks.Contact, hooks...)
  569. }
  570. // Intercept adds a list of query interceptors to the interceptors stack.
  571. // A call to `Intercept(f, g, h)` equals to `contact.Intercept(f(g(h())))`.
  572. func (c *ContactClient) Intercept(interceptors ...Interceptor) {
  573. c.inters.Contact = append(c.inters.Contact, interceptors...)
  574. }
  575. // Create returns a builder for creating a Contact entity.
  576. func (c *ContactClient) Create() *ContactCreate {
  577. mutation := newContactMutation(c.config, OpCreate)
  578. return &ContactCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  579. }
  580. // CreateBulk returns a builder for creating a bulk of Contact entities.
  581. func (c *ContactClient) CreateBulk(builders ...*ContactCreate) *ContactCreateBulk {
  582. return &ContactCreateBulk{config: c.config, builders: builders}
  583. }
  584. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  585. // a builder and applies setFunc on it.
  586. func (c *ContactClient) MapCreateBulk(slice any, setFunc func(*ContactCreate, int)) *ContactCreateBulk {
  587. rv := reflect.ValueOf(slice)
  588. if rv.Kind() != reflect.Slice {
  589. return &ContactCreateBulk{err: fmt.Errorf("calling to ContactClient.MapCreateBulk with wrong type %T, need slice", slice)}
  590. }
  591. builders := make([]*ContactCreate, rv.Len())
  592. for i := 0; i < rv.Len(); i++ {
  593. builders[i] = c.Create()
  594. setFunc(builders[i], i)
  595. }
  596. return &ContactCreateBulk{config: c.config, builders: builders}
  597. }
  598. // Update returns an update builder for Contact.
  599. func (c *ContactClient) Update() *ContactUpdate {
  600. mutation := newContactMutation(c.config, OpUpdate)
  601. return &ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  602. }
  603. // UpdateOne returns an update builder for the given entity.
  604. func (c *ContactClient) UpdateOne(co *Contact) *ContactUpdateOne {
  605. mutation := newContactMutation(c.config, OpUpdateOne, withContact(co))
  606. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  607. }
  608. // UpdateOneID returns an update builder for the given id.
  609. func (c *ContactClient) UpdateOneID(id uint64) *ContactUpdateOne {
  610. mutation := newContactMutation(c.config, OpUpdateOne, withContactID(id))
  611. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  612. }
  613. // Delete returns a delete builder for Contact.
  614. func (c *ContactClient) Delete() *ContactDelete {
  615. mutation := newContactMutation(c.config, OpDelete)
  616. return &ContactDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  617. }
  618. // DeleteOne returns a builder for deleting the given entity.
  619. func (c *ContactClient) DeleteOne(co *Contact) *ContactDeleteOne {
  620. return c.DeleteOneID(co.ID)
  621. }
  622. // DeleteOneID returns a builder for deleting the given entity by its id.
  623. func (c *ContactClient) DeleteOneID(id uint64) *ContactDeleteOne {
  624. builder := c.Delete().Where(contact.ID(id))
  625. builder.mutation.id = &id
  626. builder.mutation.op = OpDeleteOne
  627. return &ContactDeleteOne{builder}
  628. }
  629. // Query returns a query builder for Contact.
  630. func (c *ContactClient) Query() *ContactQuery {
  631. return &ContactQuery{
  632. config: c.config,
  633. ctx: &QueryContext{Type: TypeContact},
  634. inters: c.Interceptors(),
  635. }
  636. }
  637. // Get returns a Contact entity by its id.
  638. func (c *ContactClient) Get(ctx context.Context, id uint64) (*Contact, error) {
  639. return c.Query().Where(contact.ID(id)).Only(ctx)
  640. }
  641. // GetX is like Get, but panics if an error occurs.
  642. func (c *ContactClient) GetX(ctx context.Context, id uint64) *Contact {
  643. obj, err := c.Get(ctx, id)
  644. if err != nil {
  645. panic(err)
  646. }
  647. return obj
  648. }
  649. // QueryContactRelationships queries the contact_relationships edge of a Contact.
  650. func (c *ContactClient) QueryContactRelationships(co *Contact) *LabelRelationshipQuery {
  651. query := (&LabelRelationshipClient{config: c.config}).Query()
  652. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  653. id := co.ID
  654. step := sqlgraph.NewStep(
  655. sqlgraph.From(contact.Table, contact.FieldID, id),
  656. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  657. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactRelationshipsTable, contact.ContactRelationshipsColumn),
  658. )
  659. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  660. return fromV, nil
  661. }
  662. return query
  663. }
  664. // QueryContactMessages queries the contact_messages edge of a Contact.
  665. func (c *ContactClient) QueryContactMessages(co *Contact) *MessageRecordsQuery {
  666. query := (&MessageRecordsClient{config: c.config}).Query()
  667. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  668. id := co.ID
  669. step := sqlgraph.NewStep(
  670. sqlgraph.From(contact.Table, contact.FieldID, id),
  671. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  672. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactMessagesTable, contact.ContactMessagesColumn),
  673. )
  674. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  675. return fromV, nil
  676. }
  677. return query
  678. }
  679. // Hooks returns the client hooks.
  680. func (c *ContactClient) Hooks() []Hook {
  681. hooks := c.hooks.Contact
  682. return append(hooks[:len(hooks):len(hooks)], contact.Hooks[:]...)
  683. }
  684. // Interceptors returns the client interceptors.
  685. func (c *ContactClient) Interceptors() []Interceptor {
  686. inters := c.inters.Contact
  687. return append(inters[:len(inters):len(inters)], contact.Interceptors[:]...)
  688. }
  689. func (c *ContactClient) mutate(ctx context.Context, m *ContactMutation) (Value, error) {
  690. switch m.Op() {
  691. case OpCreate:
  692. return (&ContactCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  693. case OpUpdate:
  694. return (&ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  695. case OpUpdateOne:
  696. return (&ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  697. case OpDelete, OpDeleteOne:
  698. return (&ContactDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  699. default:
  700. return nil, fmt.Errorf("ent: unknown Contact mutation op: %q", m.Op())
  701. }
  702. }
  703. // EmployeeClient is a client for the Employee schema.
  704. type EmployeeClient struct {
  705. config
  706. }
  707. // NewEmployeeClient returns a client for the Employee from the given config.
  708. func NewEmployeeClient(c config) *EmployeeClient {
  709. return &EmployeeClient{config: c}
  710. }
  711. // Use adds a list of mutation hooks to the hooks stack.
  712. // A call to `Use(f, g, h)` equals to `employee.Hooks(f(g(h())))`.
  713. func (c *EmployeeClient) Use(hooks ...Hook) {
  714. c.hooks.Employee = append(c.hooks.Employee, hooks...)
  715. }
  716. // Intercept adds a list of query interceptors to the interceptors stack.
  717. // A call to `Intercept(f, g, h)` equals to `employee.Intercept(f(g(h())))`.
  718. func (c *EmployeeClient) Intercept(interceptors ...Interceptor) {
  719. c.inters.Employee = append(c.inters.Employee, interceptors...)
  720. }
  721. // Create returns a builder for creating a Employee entity.
  722. func (c *EmployeeClient) Create() *EmployeeCreate {
  723. mutation := newEmployeeMutation(c.config, OpCreate)
  724. return &EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  725. }
  726. // CreateBulk returns a builder for creating a bulk of Employee entities.
  727. func (c *EmployeeClient) CreateBulk(builders ...*EmployeeCreate) *EmployeeCreateBulk {
  728. return &EmployeeCreateBulk{config: c.config, builders: builders}
  729. }
  730. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  731. // a builder and applies setFunc on it.
  732. func (c *EmployeeClient) MapCreateBulk(slice any, setFunc func(*EmployeeCreate, int)) *EmployeeCreateBulk {
  733. rv := reflect.ValueOf(slice)
  734. if rv.Kind() != reflect.Slice {
  735. return &EmployeeCreateBulk{err: fmt.Errorf("calling to EmployeeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  736. }
  737. builders := make([]*EmployeeCreate, rv.Len())
  738. for i := 0; i < rv.Len(); i++ {
  739. builders[i] = c.Create()
  740. setFunc(builders[i], i)
  741. }
  742. return &EmployeeCreateBulk{config: c.config, builders: builders}
  743. }
  744. // Update returns an update builder for Employee.
  745. func (c *EmployeeClient) Update() *EmployeeUpdate {
  746. mutation := newEmployeeMutation(c.config, OpUpdate)
  747. return &EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  748. }
  749. // UpdateOne returns an update builder for the given entity.
  750. func (c *EmployeeClient) UpdateOne(e *Employee) *EmployeeUpdateOne {
  751. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployee(e))
  752. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  753. }
  754. // UpdateOneID returns an update builder for the given id.
  755. func (c *EmployeeClient) UpdateOneID(id uint64) *EmployeeUpdateOne {
  756. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployeeID(id))
  757. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  758. }
  759. // Delete returns a delete builder for Employee.
  760. func (c *EmployeeClient) Delete() *EmployeeDelete {
  761. mutation := newEmployeeMutation(c.config, OpDelete)
  762. return &EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  763. }
  764. // DeleteOne returns a builder for deleting the given entity.
  765. func (c *EmployeeClient) DeleteOne(e *Employee) *EmployeeDeleteOne {
  766. return c.DeleteOneID(e.ID)
  767. }
  768. // DeleteOneID returns a builder for deleting the given entity by its id.
  769. func (c *EmployeeClient) DeleteOneID(id uint64) *EmployeeDeleteOne {
  770. builder := c.Delete().Where(employee.ID(id))
  771. builder.mutation.id = &id
  772. builder.mutation.op = OpDeleteOne
  773. return &EmployeeDeleteOne{builder}
  774. }
  775. // Query returns a query builder for Employee.
  776. func (c *EmployeeClient) Query() *EmployeeQuery {
  777. return &EmployeeQuery{
  778. config: c.config,
  779. ctx: &QueryContext{Type: TypeEmployee},
  780. inters: c.Interceptors(),
  781. }
  782. }
  783. // Get returns a Employee entity by its id.
  784. func (c *EmployeeClient) Get(ctx context.Context, id uint64) (*Employee, error) {
  785. return c.Query().Where(employee.ID(id)).Only(ctx)
  786. }
  787. // GetX is like Get, but panics if an error occurs.
  788. func (c *EmployeeClient) GetX(ctx context.Context, id uint64) *Employee {
  789. obj, err := c.Get(ctx, id)
  790. if err != nil {
  791. panic(err)
  792. }
  793. return obj
  794. }
  795. // QueryEmWorkExperiences queries the em_work_experiences edge of a Employee.
  796. func (c *EmployeeClient) QueryEmWorkExperiences(e *Employee) *WorkExperienceQuery {
  797. query := (&WorkExperienceClient{config: c.config}).Query()
  798. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  799. id := e.ID
  800. step := sqlgraph.NewStep(
  801. sqlgraph.From(employee.Table, employee.FieldID, id),
  802. sqlgraph.To(workexperience.Table, workexperience.FieldID),
  803. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmWorkExperiencesTable, employee.EmWorkExperiencesColumn),
  804. )
  805. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  806. return fromV, nil
  807. }
  808. return query
  809. }
  810. // QueryEmTutorial queries the em_tutorial edge of a Employee.
  811. func (c *EmployeeClient) QueryEmTutorial(e *Employee) *TutorialQuery {
  812. query := (&TutorialClient{config: c.config}).Query()
  813. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  814. id := e.ID
  815. step := sqlgraph.NewStep(
  816. sqlgraph.From(employee.Table, employee.FieldID, id),
  817. sqlgraph.To(tutorial.Table, tutorial.FieldID),
  818. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmTutorialTable, employee.EmTutorialColumn),
  819. )
  820. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  821. return fromV, nil
  822. }
  823. return query
  824. }
  825. // Hooks returns the client hooks.
  826. func (c *EmployeeClient) Hooks() []Hook {
  827. hooks := c.hooks.Employee
  828. return append(hooks[:len(hooks):len(hooks)], employee.Hooks[:]...)
  829. }
  830. // Interceptors returns the client interceptors.
  831. func (c *EmployeeClient) Interceptors() []Interceptor {
  832. inters := c.inters.Employee
  833. return append(inters[:len(inters):len(inters)], employee.Interceptors[:]...)
  834. }
  835. func (c *EmployeeClient) mutate(ctx context.Context, m *EmployeeMutation) (Value, error) {
  836. switch m.Op() {
  837. case OpCreate:
  838. return (&EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  839. case OpUpdate:
  840. return (&EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  841. case OpUpdateOne:
  842. return (&EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  843. case OpDelete, OpDeleteOne:
  844. return (&EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  845. default:
  846. return nil, fmt.Errorf("ent: unknown Employee mutation op: %q", m.Op())
  847. }
  848. }
  849. // LabelClient is a client for the Label schema.
  850. type LabelClient struct {
  851. config
  852. }
  853. // NewLabelClient returns a client for the Label from the given config.
  854. func NewLabelClient(c config) *LabelClient {
  855. return &LabelClient{config: c}
  856. }
  857. // Use adds a list of mutation hooks to the hooks stack.
  858. // A call to `Use(f, g, h)` equals to `label.Hooks(f(g(h())))`.
  859. func (c *LabelClient) Use(hooks ...Hook) {
  860. c.hooks.Label = append(c.hooks.Label, hooks...)
  861. }
  862. // Intercept adds a list of query interceptors to the interceptors stack.
  863. // A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
  864. func (c *LabelClient) Intercept(interceptors ...Interceptor) {
  865. c.inters.Label = append(c.inters.Label, interceptors...)
  866. }
  867. // Create returns a builder for creating a Label entity.
  868. func (c *LabelClient) Create() *LabelCreate {
  869. mutation := newLabelMutation(c.config, OpCreate)
  870. return &LabelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  871. }
  872. // CreateBulk returns a builder for creating a bulk of Label entities.
  873. func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk {
  874. return &LabelCreateBulk{config: c.config, builders: builders}
  875. }
  876. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  877. // a builder and applies setFunc on it.
  878. func (c *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk {
  879. rv := reflect.ValueOf(slice)
  880. if rv.Kind() != reflect.Slice {
  881. return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)}
  882. }
  883. builders := make([]*LabelCreate, rv.Len())
  884. for i := 0; i < rv.Len(); i++ {
  885. builders[i] = c.Create()
  886. setFunc(builders[i], i)
  887. }
  888. return &LabelCreateBulk{config: c.config, builders: builders}
  889. }
  890. // Update returns an update builder for Label.
  891. func (c *LabelClient) Update() *LabelUpdate {
  892. mutation := newLabelMutation(c.config, OpUpdate)
  893. return &LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  894. }
  895. // UpdateOne returns an update builder for the given entity.
  896. func (c *LabelClient) UpdateOne(l *Label) *LabelUpdateOne {
  897. mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(l))
  898. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  899. }
  900. // UpdateOneID returns an update builder for the given id.
  901. func (c *LabelClient) UpdateOneID(id uint64) *LabelUpdateOne {
  902. mutation := newLabelMutation(c.config, OpUpdateOne, withLabelID(id))
  903. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  904. }
  905. // Delete returns a delete builder for Label.
  906. func (c *LabelClient) Delete() *LabelDelete {
  907. mutation := newLabelMutation(c.config, OpDelete)
  908. return &LabelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  909. }
  910. // DeleteOne returns a builder for deleting the given entity.
  911. func (c *LabelClient) DeleteOne(l *Label) *LabelDeleteOne {
  912. return c.DeleteOneID(l.ID)
  913. }
  914. // DeleteOneID returns a builder for deleting the given entity by its id.
  915. func (c *LabelClient) DeleteOneID(id uint64) *LabelDeleteOne {
  916. builder := c.Delete().Where(label.ID(id))
  917. builder.mutation.id = &id
  918. builder.mutation.op = OpDeleteOne
  919. return &LabelDeleteOne{builder}
  920. }
  921. // Query returns a query builder for Label.
  922. func (c *LabelClient) Query() *LabelQuery {
  923. return &LabelQuery{
  924. config: c.config,
  925. ctx: &QueryContext{Type: TypeLabel},
  926. inters: c.Interceptors(),
  927. }
  928. }
  929. // Get returns a Label entity by its id.
  930. func (c *LabelClient) Get(ctx context.Context, id uint64) (*Label, error) {
  931. return c.Query().Where(label.ID(id)).Only(ctx)
  932. }
  933. // GetX is like Get, but panics if an error occurs.
  934. func (c *LabelClient) GetX(ctx context.Context, id uint64) *Label {
  935. obj, err := c.Get(ctx, id)
  936. if err != nil {
  937. panic(err)
  938. }
  939. return obj
  940. }
  941. // QueryLabelRelationships queries the label_relationships edge of a Label.
  942. func (c *LabelClient) QueryLabelRelationships(l *Label) *LabelRelationshipQuery {
  943. query := (&LabelRelationshipClient{config: c.config}).Query()
  944. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  945. id := l.ID
  946. step := sqlgraph.NewStep(
  947. sqlgraph.From(label.Table, label.FieldID, id),
  948. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  949. sqlgraph.Edge(sqlgraph.O2M, false, label.LabelRelationshipsTable, label.LabelRelationshipsColumn),
  950. )
  951. fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
  952. return fromV, nil
  953. }
  954. return query
  955. }
  956. // Hooks returns the client hooks.
  957. func (c *LabelClient) Hooks() []Hook {
  958. return c.hooks.Label
  959. }
  960. // Interceptors returns the client interceptors.
  961. func (c *LabelClient) Interceptors() []Interceptor {
  962. return c.inters.Label
  963. }
  964. func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
  965. switch m.Op() {
  966. case OpCreate:
  967. return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  968. case OpUpdate:
  969. return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  970. case OpUpdateOne:
  971. return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  972. case OpDelete, OpDeleteOne:
  973. return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  974. default:
  975. return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
  976. }
  977. }
  978. // LabelRelationshipClient is a client for the LabelRelationship schema.
  979. type LabelRelationshipClient struct {
  980. config
  981. }
  982. // NewLabelRelationshipClient returns a client for the LabelRelationship from the given config.
  983. func NewLabelRelationshipClient(c config) *LabelRelationshipClient {
  984. return &LabelRelationshipClient{config: c}
  985. }
  986. // Use adds a list of mutation hooks to the hooks stack.
  987. // A call to `Use(f, g, h)` equals to `labelrelationship.Hooks(f(g(h())))`.
  988. func (c *LabelRelationshipClient) Use(hooks ...Hook) {
  989. c.hooks.LabelRelationship = append(c.hooks.LabelRelationship, hooks...)
  990. }
  991. // Intercept adds a list of query interceptors to the interceptors stack.
  992. // A call to `Intercept(f, g, h)` equals to `labelrelationship.Intercept(f(g(h())))`.
  993. func (c *LabelRelationshipClient) Intercept(interceptors ...Interceptor) {
  994. c.inters.LabelRelationship = append(c.inters.LabelRelationship, interceptors...)
  995. }
  996. // Create returns a builder for creating a LabelRelationship entity.
  997. func (c *LabelRelationshipClient) Create() *LabelRelationshipCreate {
  998. mutation := newLabelRelationshipMutation(c.config, OpCreate)
  999. return &LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1000. }
  1001. // CreateBulk returns a builder for creating a bulk of LabelRelationship entities.
  1002. func (c *LabelRelationshipClient) CreateBulk(builders ...*LabelRelationshipCreate) *LabelRelationshipCreateBulk {
  1003. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1004. }
  1005. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1006. // a builder and applies setFunc on it.
  1007. func (c *LabelRelationshipClient) MapCreateBulk(slice any, setFunc func(*LabelRelationshipCreate, int)) *LabelRelationshipCreateBulk {
  1008. rv := reflect.ValueOf(slice)
  1009. if rv.Kind() != reflect.Slice {
  1010. return &LabelRelationshipCreateBulk{err: fmt.Errorf("calling to LabelRelationshipClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1011. }
  1012. builders := make([]*LabelRelationshipCreate, rv.Len())
  1013. for i := 0; i < rv.Len(); i++ {
  1014. builders[i] = c.Create()
  1015. setFunc(builders[i], i)
  1016. }
  1017. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1018. }
  1019. // Update returns an update builder for LabelRelationship.
  1020. func (c *LabelRelationshipClient) Update() *LabelRelationshipUpdate {
  1021. mutation := newLabelRelationshipMutation(c.config, OpUpdate)
  1022. return &LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1023. }
  1024. // UpdateOne returns an update builder for the given entity.
  1025. func (c *LabelRelationshipClient) UpdateOne(lr *LabelRelationship) *LabelRelationshipUpdateOne {
  1026. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationship(lr))
  1027. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1028. }
  1029. // UpdateOneID returns an update builder for the given id.
  1030. func (c *LabelRelationshipClient) UpdateOneID(id uint64) *LabelRelationshipUpdateOne {
  1031. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationshipID(id))
  1032. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1033. }
  1034. // Delete returns a delete builder for LabelRelationship.
  1035. func (c *LabelRelationshipClient) Delete() *LabelRelationshipDelete {
  1036. mutation := newLabelRelationshipMutation(c.config, OpDelete)
  1037. return &LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1038. }
  1039. // DeleteOne returns a builder for deleting the given entity.
  1040. func (c *LabelRelationshipClient) DeleteOne(lr *LabelRelationship) *LabelRelationshipDeleteOne {
  1041. return c.DeleteOneID(lr.ID)
  1042. }
  1043. // DeleteOneID returns a builder for deleting the given entity by its id.
  1044. func (c *LabelRelationshipClient) DeleteOneID(id uint64) *LabelRelationshipDeleteOne {
  1045. builder := c.Delete().Where(labelrelationship.ID(id))
  1046. builder.mutation.id = &id
  1047. builder.mutation.op = OpDeleteOne
  1048. return &LabelRelationshipDeleteOne{builder}
  1049. }
  1050. // Query returns a query builder for LabelRelationship.
  1051. func (c *LabelRelationshipClient) Query() *LabelRelationshipQuery {
  1052. return &LabelRelationshipQuery{
  1053. config: c.config,
  1054. ctx: &QueryContext{Type: TypeLabelRelationship},
  1055. inters: c.Interceptors(),
  1056. }
  1057. }
  1058. // Get returns a LabelRelationship entity by its id.
  1059. func (c *LabelRelationshipClient) Get(ctx context.Context, id uint64) (*LabelRelationship, error) {
  1060. return c.Query().Where(labelrelationship.ID(id)).Only(ctx)
  1061. }
  1062. // GetX is like Get, but panics if an error occurs.
  1063. func (c *LabelRelationshipClient) GetX(ctx context.Context, id uint64) *LabelRelationship {
  1064. obj, err := c.Get(ctx, id)
  1065. if err != nil {
  1066. panic(err)
  1067. }
  1068. return obj
  1069. }
  1070. // QueryContacts queries the contacts edge of a LabelRelationship.
  1071. func (c *LabelRelationshipClient) QueryContacts(lr *LabelRelationship) *ContactQuery {
  1072. query := (&ContactClient{config: c.config}).Query()
  1073. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1074. id := lr.ID
  1075. step := sqlgraph.NewStep(
  1076. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1077. sqlgraph.To(contact.Table, contact.FieldID),
  1078. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.ContactsTable, labelrelationship.ContactsColumn),
  1079. )
  1080. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1081. return fromV, nil
  1082. }
  1083. return query
  1084. }
  1085. // QueryLabels queries the labels edge of a LabelRelationship.
  1086. func (c *LabelRelationshipClient) QueryLabels(lr *LabelRelationship) *LabelQuery {
  1087. query := (&LabelClient{config: c.config}).Query()
  1088. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1089. id := lr.ID
  1090. step := sqlgraph.NewStep(
  1091. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1092. sqlgraph.To(label.Table, label.FieldID),
  1093. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.LabelsTable, labelrelationship.LabelsColumn),
  1094. )
  1095. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1096. return fromV, nil
  1097. }
  1098. return query
  1099. }
  1100. // Hooks returns the client hooks.
  1101. func (c *LabelRelationshipClient) Hooks() []Hook {
  1102. hooks := c.hooks.LabelRelationship
  1103. return append(hooks[:len(hooks):len(hooks)], labelrelationship.Hooks[:]...)
  1104. }
  1105. // Interceptors returns the client interceptors.
  1106. func (c *LabelRelationshipClient) Interceptors() []Interceptor {
  1107. inters := c.inters.LabelRelationship
  1108. return append(inters[:len(inters):len(inters)], labelrelationship.Interceptors[:]...)
  1109. }
  1110. func (c *LabelRelationshipClient) mutate(ctx context.Context, m *LabelRelationshipMutation) (Value, error) {
  1111. switch m.Op() {
  1112. case OpCreate:
  1113. return (&LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1114. case OpUpdate:
  1115. return (&LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1116. case OpUpdateOne:
  1117. return (&LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1118. case OpDelete, OpDeleteOne:
  1119. return (&LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1120. default:
  1121. return nil, fmt.Errorf("ent: unknown LabelRelationship mutation op: %q", m.Op())
  1122. }
  1123. }
  1124. // MessageClient is a client for the Message schema.
  1125. type MessageClient struct {
  1126. config
  1127. }
  1128. // NewMessageClient returns a client for the Message from the given config.
  1129. func NewMessageClient(c config) *MessageClient {
  1130. return &MessageClient{config: c}
  1131. }
  1132. // Use adds a list of mutation hooks to the hooks stack.
  1133. // A call to `Use(f, g, h)` equals to `message.Hooks(f(g(h())))`.
  1134. func (c *MessageClient) Use(hooks ...Hook) {
  1135. c.hooks.Message = append(c.hooks.Message, hooks...)
  1136. }
  1137. // Intercept adds a list of query interceptors to the interceptors stack.
  1138. // A call to `Intercept(f, g, h)` equals to `message.Intercept(f(g(h())))`.
  1139. func (c *MessageClient) Intercept(interceptors ...Interceptor) {
  1140. c.inters.Message = append(c.inters.Message, interceptors...)
  1141. }
  1142. // Create returns a builder for creating a Message entity.
  1143. func (c *MessageClient) Create() *MessageCreate {
  1144. mutation := newMessageMutation(c.config, OpCreate)
  1145. return &MessageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1146. }
  1147. // CreateBulk returns a builder for creating a bulk of Message entities.
  1148. func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBulk {
  1149. return &MessageCreateBulk{config: c.config, builders: builders}
  1150. }
  1151. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1152. // a builder and applies setFunc on it.
  1153. func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk {
  1154. rv := reflect.ValueOf(slice)
  1155. if rv.Kind() != reflect.Slice {
  1156. return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1157. }
  1158. builders := make([]*MessageCreate, rv.Len())
  1159. for i := 0; i < rv.Len(); i++ {
  1160. builders[i] = c.Create()
  1161. setFunc(builders[i], i)
  1162. }
  1163. return &MessageCreateBulk{config: c.config, builders: builders}
  1164. }
  1165. // Update returns an update builder for Message.
  1166. func (c *MessageClient) Update() *MessageUpdate {
  1167. mutation := newMessageMutation(c.config, OpUpdate)
  1168. return &MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1169. }
  1170. // UpdateOne returns an update builder for the given entity.
  1171. func (c *MessageClient) UpdateOne(m *Message) *MessageUpdateOne {
  1172. mutation := newMessageMutation(c.config, OpUpdateOne, withMessage(m))
  1173. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1174. }
  1175. // UpdateOneID returns an update builder for the given id.
  1176. func (c *MessageClient) UpdateOneID(id int) *MessageUpdateOne {
  1177. mutation := newMessageMutation(c.config, OpUpdateOne, withMessageID(id))
  1178. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1179. }
  1180. // Delete returns a delete builder for Message.
  1181. func (c *MessageClient) Delete() *MessageDelete {
  1182. mutation := newMessageMutation(c.config, OpDelete)
  1183. return &MessageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1184. }
  1185. // DeleteOne returns a builder for deleting the given entity.
  1186. func (c *MessageClient) DeleteOne(m *Message) *MessageDeleteOne {
  1187. return c.DeleteOneID(m.ID)
  1188. }
  1189. // DeleteOneID returns a builder for deleting the given entity by its id.
  1190. func (c *MessageClient) DeleteOneID(id int) *MessageDeleteOne {
  1191. builder := c.Delete().Where(message.ID(id))
  1192. builder.mutation.id = &id
  1193. builder.mutation.op = OpDeleteOne
  1194. return &MessageDeleteOne{builder}
  1195. }
  1196. // Query returns a query builder for Message.
  1197. func (c *MessageClient) Query() *MessageQuery {
  1198. return &MessageQuery{
  1199. config: c.config,
  1200. ctx: &QueryContext{Type: TypeMessage},
  1201. inters: c.Interceptors(),
  1202. }
  1203. }
  1204. // Get returns a Message entity by its id.
  1205. func (c *MessageClient) Get(ctx context.Context, id int) (*Message, error) {
  1206. return c.Query().Where(message.ID(id)).Only(ctx)
  1207. }
  1208. // GetX is like Get, but panics if an error occurs.
  1209. func (c *MessageClient) GetX(ctx context.Context, id int) *Message {
  1210. obj, err := c.Get(ctx, id)
  1211. if err != nil {
  1212. panic(err)
  1213. }
  1214. return obj
  1215. }
  1216. // Hooks returns the client hooks.
  1217. func (c *MessageClient) Hooks() []Hook {
  1218. return c.hooks.Message
  1219. }
  1220. // Interceptors returns the client interceptors.
  1221. func (c *MessageClient) Interceptors() []Interceptor {
  1222. return c.inters.Message
  1223. }
  1224. func (c *MessageClient) mutate(ctx context.Context, m *MessageMutation) (Value, error) {
  1225. switch m.Op() {
  1226. case OpCreate:
  1227. return (&MessageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1228. case OpUpdate:
  1229. return (&MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1230. case OpUpdateOne:
  1231. return (&MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1232. case OpDelete, OpDeleteOne:
  1233. return (&MessageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1234. default:
  1235. return nil, fmt.Errorf("ent: unknown Message mutation op: %q", m.Op())
  1236. }
  1237. }
  1238. // MessageRecordsClient is a client for the MessageRecords schema.
  1239. type MessageRecordsClient struct {
  1240. config
  1241. }
  1242. // NewMessageRecordsClient returns a client for the MessageRecords from the given config.
  1243. func NewMessageRecordsClient(c config) *MessageRecordsClient {
  1244. return &MessageRecordsClient{config: c}
  1245. }
  1246. // Use adds a list of mutation hooks to the hooks stack.
  1247. // A call to `Use(f, g, h)` equals to `messagerecords.Hooks(f(g(h())))`.
  1248. func (c *MessageRecordsClient) Use(hooks ...Hook) {
  1249. c.hooks.MessageRecords = append(c.hooks.MessageRecords, hooks...)
  1250. }
  1251. // Intercept adds a list of query interceptors to the interceptors stack.
  1252. // A call to `Intercept(f, g, h)` equals to `messagerecords.Intercept(f(g(h())))`.
  1253. func (c *MessageRecordsClient) Intercept(interceptors ...Interceptor) {
  1254. c.inters.MessageRecords = append(c.inters.MessageRecords, interceptors...)
  1255. }
  1256. // Create returns a builder for creating a MessageRecords entity.
  1257. func (c *MessageRecordsClient) Create() *MessageRecordsCreate {
  1258. mutation := newMessageRecordsMutation(c.config, OpCreate)
  1259. return &MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1260. }
  1261. // CreateBulk returns a builder for creating a bulk of MessageRecords entities.
  1262. func (c *MessageRecordsClient) CreateBulk(builders ...*MessageRecordsCreate) *MessageRecordsCreateBulk {
  1263. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1264. }
  1265. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1266. // a builder and applies setFunc on it.
  1267. func (c *MessageRecordsClient) MapCreateBulk(slice any, setFunc func(*MessageRecordsCreate, int)) *MessageRecordsCreateBulk {
  1268. rv := reflect.ValueOf(slice)
  1269. if rv.Kind() != reflect.Slice {
  1270. return &MessageRecordsCreateBulk{err: fmt.Errorf("calling to MessageRecordsClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1271. }
  1272. builders := make([]*MessageRecordsCreate, rv.Len())
  1273. for i := 0; i < rv.Len(); i++ {
  1274. builders[i] = c.Create()
  1275. setFunc(builders[i], i)
  1276. }
  1277. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1278. }
  1279. // Update returns an update builder for MessageRecords.
  1280. func (c *MessageRecordsClient) Update() *MessageRecordsUpdate {
  1281. mutation := newMessageRecordsMutation(c.config, OpUpdate)
  1282. return &MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1283. }
  1284. // UpdateOne returns an update builder for the given entity.
  1285. func (c *MessageRecordsClient) UpdateOne(mr *MessageRecords) *MessageRecordsUpdateOne {
  1286. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecords(mr))
  1287. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1288. }
  1289. // UpdateOneID returns an update builder for the given id.
  1290. func (c *MessageRecordsClient) UpdateOneID(id uint64) *MessageRecordsUpdateOne {
  1291. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecordsID(id))
  1292. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1293. }
  1294. // Delete returns a delete builder for MessageRecords.
  1295. func (c *MessageRecordsClient) Delete() *MessageRecordsDelete {
  1296. mutation := newMessageRecordsMutation(c.config, OpDelete)
  1297. return &MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1298. }
  1299. // DeleteOne returns a builder for deleting the given entity.
  1300. func (c *MessageRecordsClient) DeleteOne(mr *MessageRecords) *MessageRecordsDeleteOne {
  1301. return c.DeleteOneID(mr.ID)
  1302. }
  1303. // DeleteOneID returns a builder for deleting the given entity by its id.
  1304. func (c *MessageRecordsClient) DeleteOneID(id uint64) *MessageRecordsDeleteOne {
  1305. builder := c.Delete().Where(messagerecords.ID(id))
  1306. builder.mutation.id = &id
  1307. builder.mutation.op = OpDeleteOne
  1308. return &MessageRecordsDeleteOne{builder}
  1309. }
  1310. // Query returns a query builder for MessageRecords.
  1311. func (c *MessageRecordsClient) Query() *MessageRecordsQuery {
  1312. return &MessageRecordsQuery{
  1313. config: c.config,
  1314. ctx: &QueryContext{Type: TypeMessageRecords},
  1315. inters: c.Interceptors(),
  1316. }
  1317. }
  1318. // Get returns a MessageRecords entity by its id.
  1319. func (c *MessageRecordsClient) Get(ctx context.Context, id uint64) (*MessageRecords, error) {
  1320. return c.Query().Where(messagerecords.ID(id)).Only(ctx)
  1321. }
  1322. // GetX is like Get, but panics if an error occurs.
  1323. func (c *MessageRecordsClient) GetX(ctx context.Context, id uint64) *MessageRecords {
  1324. obj, err := c.Get(ctx, id)
  1325. if err != nil {
  1326. panic(err)
  1327. }
  1328. return obj
  1329. }
  1330. // QuerySopStage queries the sop_stage edge of a MessageRecords.
  1331. func (c *MessageRecordsClient) QuerySopStage(mr *MessageRecords) *SopStageQuery {
  1332. query := (&SopStageClient{config: c.config}).Query()
  1333. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1334. id := mr.ID
  1335. step := sqlgraph.NewStep(
  1336. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1337. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  1338. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopStageTable, messagerecords.SopStageColumn),
  1339. )
  1340. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1341. return fromV, nil
  1342. }
  1343. return query
  1344. }
  1345. // QuerySopNode queries the sop_node edge of a MessageRecords.
  1346. func (c *MessageRecordsClient) QuerySopNode(mr *MessageRecords) *SopNodeQuery {
  1347. query := (&SopNodeClient{config: c.config}).Query()
  1348. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1349. id := mr.ID
  1350. step := sqlgraph.NewStep(
  1351. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1352. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  1353. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopNodeTable, messagerecords.SopNodeColumn),
  1354. )
  1355. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1356. return fromV, nil
  1357. }
  1358. return query
  1359. }
  1360. // QueryMessageContact queries the message_contact edge of a MessageRecords.
  1361. func (c *MessageRecordsClient) QueryMessageContact(mr *MessageRecords) *ContactQuery {
  1362. query := (&ContactClient{config: c.config}).Query()
  1363. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1364. id := mr.ID
  1365. step := sqlgraph.NewStep(
  1366. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1367. sqlgraph.To(contact.Table, contact.FieldID),
  1368. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.MessageContactTable, messagerecords.MessageContactColumn),
  1369. )
  1370. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1371. return fromV, nil
  1372. }
  1373. return query
  1374. }
  1375. // Hooks returns the client hooks.
  1376. func (c *MessageRecordsClient) Hooks() []Hook {
  1377. hooks := c.hooks.MessageRecords
  1378. return append(hooks[:len(hooks):len(hooks)], messagerecords.Hooks[:]...)
  1379. }
  1380. // Interceptors returns the client interceptors.
  1381. func (c *MessageRecordsClient) Interceptors() []Interceptor {
  1382. inters := c.inters.MessageRecords
  1383. return append(inters[:len(inters):len(inters)], messagerecords.Interceptors[:]...)
  1384. }
  1385. func (c *MessageRecordsClient) mutate(ctx context.Context, m *MessageRecordsMutation) (Value, error) {
  1386. switch m.Op() {
  1387. case OpCreate:
  1388. return (&MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1389. case OpUpdate:
  1390. return (&MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1391. case OpUpdateOne:
  1392. return (&MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1393. case OpDelete, OpDeleteOne:
  1394. return (&MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1395. default:
  1396. return nil, fmt.Errorf("ent: unknown MessageRecords mutation op: %q", m.Op())
  1397. }
  1398. }
  1399. // MsgClient is a client for the Msg schema.
  1400. type MsgClient struct {
  1401. config
  1402. }
  1403. // NewMsgClient returns a client for the Msg from the given config.
  1404. func NewMsgClient(c config) *MsgClient {
  1405. return &MsgClient{config: c}
  1406. }
  1407. // Use adds a list of mutation hooks to the hooks stack.
  1408. // A call to `Use(f, g, h)` equals to `msg.Hooks(f(g(h())))`.
  1409. func (c *MsgClient) Use(hooks ...Hook) {
  1410. c.hooks.Msg = append(c.hooks.Msg, hooks...)
  1411. }
  1412. // Intercept adds a list of query interceptors to the interceptors stack.
  1413. // A call to `Intercept(f, g, h)` equals to `msg.Intercept(f(g(h())))`.
  1414. func (c *MsgClient) Intercept(interceptors ...Interceptor) {
  1415. c.inters.Msg = append(c.inters.Msg, interceptors...)
  1416. }
  1417. // Create returns a builder for creating a Msg entity.
  1418. func (c *MsgClient) Create() *MsgCreate {
  1419. mutation := newMsgMutation(c.config, OpCreate)
  1420. return &MsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1421. }
  1422. // CreateBulk returns a builder for creating a bulk of Msg entities.
  1423. func (c *MsgClient) CreateBulk(builders ...*MsgCreate) *MsgCreateBulk {
  1424. return &MsgCreateBulk{config: c.config, builders: builders}
  1425. }
  1426. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1427. // a builder and applies setFunc on it.
  1428. func (c *MsgClient) MapCreateBulk(slice any, setFunc func(*MsgCreate, int)) *MsgCreateBulk {
  1429. rv := reflect.ValueOf(slice)
  1430. if rv.Kind() != reflect.Slice {
  1431. return &MsgCreateBulk{err: fmt.Errorf("calling to MsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1432. }
  1433. builders := make([]*MsgCreate, rv.Len())
  1434. for i := 0; i < rv.Len(); i++ {
  1435. builders[i] = c.Create()
  1436. setFunc(builders[i], i)
  1437. }
  1438. return &MsgCreateBulk{config: c.config, builders: builders}
  1439. }
  1440. // Update returns an update builder for Msg.
  1441. func (c *MsgClient) Update() *MsgUpdate {
  1442. mutation := newMsgMutation(c.config, OpUpdate)
  1443. return &MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1444. }
  1445. // UpdateOne returns an update builder for the given entity.
  1446. func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
  1447. mutation := newMsgMutation(c.config, OpUpdateOne, withMsg(m))
  1448. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1449. }
  1450. // UpdateOneID returns an update builder for the given id.
  1451. func (c *MsgClient) UpdateOneID(id uint64) *MsgUpdateOne {
  1452. mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
  1453. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1454. }
  1455. // Delete returns a delete builder for Msg.
  1456. func (c *MsgClient) Delete() *MsgDelete {
  1457. mutation := newMsgMutation(c.config, OpDelete)
  1458. return &MsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1459. }
  1460. // DeleteOne returns a builder for deleting the given entity.
  1461. func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
  1462. return c.DeleteOneID(m.ID)
  1463. }
  1464. // DeleteOneID returns a builder for deleting the given entity by its id.
  1465. func (c *MsgClient) DeleteOneID(id uint64) *MsgDeleteOne {
  1466. builder := c.Delete().Where(msg.ID(id))
  1467. builder.mutation.id = &id
  1468. builder.mutation.op = OpDeleteOne
  1469. return &MsgDeleteOne{builder}
  1470. }
  1471. // Query returns a query builder for Msg.
  1472. func (c *MsgClient) Query() *MsgQuery {
  1473. return &MsgQuery{
  1474. config: c.config,
  1475. ctx: &QueryContext{Type: TypeMsg},
  1476. inters: c.Interceptors(),
  1477. }
  1478. }
  1479. // Get returns a Msg entity by its id.
  1480. func (c *MsgClient) Get(ctx context.Context, id uint64) (*Msg, error) {
  1481. return c.Query().Where(msg.ID(id)).Only(ctx)
  1482. }
  1483. // GetX is like Get, but panics if an error occurs.
  1484. func (c *MsgClient) GetX(ctx context.Context, id uint64) *Msg {
  1485. obj, err := c.Get(ctx, id)
  1486. if err != nil {
  1487. panic(err)
  1488. }
  1489. return obj
  1490. }
  1491. // Hooks returns the client hooks.
  1492. func (c *MsgClient) Hooks() []Hook {
  1493. hooks := c.hooks.Msg
  1494. return append(hooks[:len(hooks):len(hooks)], msg.Hooks[:]...)
  1495. }
  1496. // Interceptors returns the client interceptors.
  1497. func (c *MsgClient) Interceptors() []Interceptor {
  1498. inters := c.inters.Msg
  1499. return append(inters[:len(inters):len(inters)], msg.Interceptors[:]...)
  1500. }
  1501. func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
  1502. switch m.Op() {
  1503. case OpCreate:
  1504. return (&MsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1505. case OpUpdate:
  1506. return (&MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1507. case OpUpdateOne:
  1508. return (&MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1509. case OpDelete, OpDeleteOne:
  1510. return (&MsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1511. default:
  1512. return nil, fmt.Errorf("ent: unknown Msg mutation op: %q", m.Op())
  1513. }
  1514. }
  1515. // ServerClient is a client for the Server schema.
  1516. type ServerClient struct {
  1517. config
  1518. }
  1519. // NewServerClient returns a client for the Server from the given config.
  1520. func NewServerClient(c config) *ServerClient {
  1521. return &ServerClient{config: c}
  1522. }
  1523. // Use adds a list of mutation hooks to the hooks stack.
  1524. // A call to `Use(f, g, h)` equals to `server.Hooks(f(g(h())))`.
  1525. func (c *ServerClient) Use(hooks ...Hook) {
  1526. c.hooks.Server = append(c.hooks.Server, hooks...)
  1527. }
  1528. // Intercept adds a list of query interceptors to the interceptors stack.
  1529. // A call to `Intercept(f, g, h)` equals to `server.Intercept(f(g(h())))`.
  1530. func (c *ServerClient) Intercept(interceptors ...Interceptor) {
  1531. c.inters.Server = append(c.inters.Server, interceptors...)
  1532. }
  1533. // Create returns a builder for creating a Server entity.
  1534. func (c *ServerClient) Create() *ServerCreate {
  1535. mutation := newServerMutation(c.config, OpCreate)
  1536. return &ServerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1537. }
  1538. // CreateBulk returns a builder for creating a bulk of Server entities.
  1539. func (c *ServerClient) CreateBulk(builders ...*ServerCreate) *ServerCreateBulk {
  1540. return &ServerCreateBulk{config: c.config, builders: builders}
  1541. }
  1542. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1543. // a builder and applies setFunc on it.
  1544. func (c *ServerClient) MapCreateBulk(slice any, setFunc func(*ServerCreate, int)) *ServerCreateBulk {
  1545. rv := reflect.ValueOf(slice)
  1546. if rv.Kind() != reflect.Slice {
  1547. return &ServerCreateBulk{err: fmt.Errorf("calling to ServerClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1548. }
  1549. builders := make([]*ServerCreate, rv.Len())
  1550. for i := 0; i < rv.Len(); i++ {
  1551. builders[i] = c.Create()
  1552. setFunc(builders[i], i)
  1553. }
  1554. return &ServerCreateBulk{config: c.config, builders: builders}
  1555. }
  1556. // Update returns an update builder for Server.
  1557. func (c *ServerClient) Update() *ServerUpdate {
  1558. mutation := newServerMutation(c.config, OpUpdate)
  1559. return &ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1560. }
  1561. // UpdateOne returns an update builder for the given entity.
  1562. func (c *ServerClient) UpdateOne(s *Server) *ServerUpdateOne {
  1563. mutation := newServerMutation(c.config, OpUpdateOne, withServer(s))
  1564. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1565. }
  1566. // UpdateOneID returns an update builder for the given id.
  1567. func (c *ServerClient) UpdateOneID(id uint64) *ServerUpdateOne {
  1568. mutation := newServerMutation(c.config, OpUpdateOne, withServerID(id))
  1569. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1570. }
  1571. // Delete returns a delete builder for Server.
  1572. func (c *ServerClient) Delete() *ServerDelete {
  1573. mutation := newServerMutation(c.config, OpDelete)
  1574. return &ServerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1575. }
  1576. // DeleteOne returns a builder for deleting the given entity.
  1577. func (c *ServerClient) DeleteOne(s *Server) *ServerDeleteOne {
  1578. return c.DeleteOneID(s.ID)
  1579. }
  1580. // DeleteOneID returns a builder for deleting the given entity by its id.
  1581. func (c *ServerClient) DeleteOneID(id uint64) *ServerDeleteOne {
  1582. builder := c.Delete().Where(server.ID(id))
  1583. builder.mutation.id = &id
  1584. builder.mutation.op = OpDeleteOne
  1585. return &ServerDeleteOne{builder}
  1586. }
  1587. // Query returns a query builder for Server.
  1588. func (c *ServerClient) Query() *ServerQuery {
  1589. return &ServerQuery{
  1590. config: c.config,
  1591. ctx: &QueryContext{Type: TypeServer},
  1592. inters: c.Interceptors(),
  1593. }
  1594. }
  1595. // Get returns a Server entity by its id.
  1596. func (c *ServerClient) Get(ctx context.Context, id uint64) (*Server, error) {
  1597. return c.Query().Where(server.ID(id)).Only(ctx)
  1598. }
  1599. // GetX is like Get, but panics if an error occurs.
  1600. func (c *ServerClient) GetX(ctx context.Context, id uint64) *Server {
  1601. obj, err := c.Get(ctx, id)
  1602. if err != nil {
  1603. panic(err)
  1604. }
  1605. return obj
  1606. }
  1607. // QueryWxs queries the wxs edge of a Server.
  1608. func (c *ServerClient) QueryWxs(s *Server) *WxQuery {
  1609. query := (&WxClient{config: c.config}).Query()
  1610. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1611. id := s.ID
  1612. step := sqlgraph.NewStep(
  1613. sqlgraph.From(server.Table, server.FieldID, id),
  1614. sqlgraph.To(wx.Table, wx.FieldID),
  1615. sqlgraph.Edge(sqlgraph.O2M, false, server.WxsTable, server.WxsColumn),
  1616. )
  1617. fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
  1618. return fromV, nil
  1619. }
  1620. return query
  1621. }
  1622. // Hooks returns the client hooks.
  1623. func (c *ServerClient) Hooks() []Hook {
  1624. hooks := c.hooks.Server
  1625. return append(hooks[:len(hooks):len(hooks)], server.Hooks[:]...)
  1626. }
  1627. // Interceptors returns the client interceptors.
  1628. func (c *ServerClient) Interceptors() []Interceptor {
  1629. inters := c.inters.Server
  1630. return append(inters[:len(inters):len(inters)], server.Interceptors[:]...)
  1631. }
  1632. func (c *ServerClient) mutate(ctx context.Context, m *ServerMutation) (Value, error) {
  1633. switch m.Op() {
  1634. case OpCreate:
  1635. return (&ServerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1636. case OpUpdate:
  1637. return (&ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1638. case OpUpdateOne:
  1639. return (&ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1640. case OpDelete, OpDeleteOne:
  1641. return (&ServerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1642. default:
  1643. return nil, fmt.Errorf("ent: unknown Server mutation op: %q", m.Op())
  1644. }
  1645. }
  1646. // SopNodeClient is a client for the SopNode schema.
  1647. type SopNodeClient struct {
  1648. config
  1649. }
  1650. // NewSopNodeClient returns a client for the SopNode from the given config.
  1651. func NewSopNodeClient(c config) *SopNodeClient {
  1652. return &SopNodeClient{config: c}
  1653. }
  1654. // Use adds a list of mutation hooks to the hooks stack.
  1655. // A call to `Use(f, g, h)` equals to `sopnode.Hooks(f(g(h())))`.
  1656. func (c *SopNodeClient) Use(hooks ...Hook) {
  1657. c.hooks.SopNode = append(c.hooks.SopNode, hooks...)
  1658. }
  1659. // Intercept adds a list of query interceptors to the interceptors stack.
  1660. // A call to `Intercept(f, g, h)` equals to `sopnode.Intercept(f(g(h())))`.
  1661. func (c *SopNodeClient) Intercept(interceptors ...Interceptor) {
  1662. c.inters.SopNode = append(c.inters.SopNode, interceptors...)
  1663. }
  1664. // Create returns a builder for creating a SopNode entity.
  1665. func (c *SopNodeClient) Create() *SopNodeCreate {
  1666. mutation := newSopNodeMutation(c.config, OpCreate)
  1667. return &SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1668. }
  1669. // CreateBulk returns a builder for creating a bulk of SopNode entities.
  1670. func (c *SopNodeClient) CreateBulk(builders ...*SopNodeCreate) *SopNodeCreateBulk {
  1671. return &SopNodeCreateBulk{config: c.config, builders: builders}
  1672. }
  1673. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1674. // a builder and applies setFunc on it.
  1675. func (c *SopNodeClient) MapCreateBulk(slice any, setFunc func(*SopNodeCreate, int)) *SopNodeCreateBulk {
  1676. rv := reflect.ValueOf(slice)
  1677. if rv.Kind() != reflect.Slice {
  1678. return &SopNodeCreateBulk{err: fmt.Errorf("calling to SopNodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1679. }
  1680. builders := make([]*SopNodeCreate, rv.Len())
  1681. for i := 0; i < rv.Len(); i++ {
  1682. builders[i] = c.Create()
  1683. setFunc(builders[i], i)
  1684. }
  1685. return &SopNodeCreateBulk{config: c.config, builders: builders}
  1686. }
  1687. // Update returns an update builder for SopNode.
  1688. func (c *SopNodeClient) Update() *SopNodeUpdate {
  1689. mutation := newSopNodeMutation(c.config, OpUpdate)
  1690. return &SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1691. }
  1692. // UpdateOne returns an update builder for the given entity.
  1693. func (c *SopNodeClient) UpdateOne(sn *SopNode) *SopNodeUpdateOne {
  1694. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNode(sn))
  1695. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1696. }
  1697. // UpdateOneID returns an update builder for the given id.
  1698. func (c *SopNodeClient) UpdateOneID(id uint64) *SopNodeUpdateOne {
  1699. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNodeID(id))
  1700. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1701. }
  1702. // Delete returns a delete builder for SopNode.
  1703. func (c *SopNodeClient) Delete() *SopNodeDelete {
  1704. mutation := newSopNodeMutation(c.config, OpDelete)
  1705. return &SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1706. }
  1707. // DeleteOne returns a builder for deleting the given entity.
  1708. func (c *SopNodeClient) DeleteOne(sn *SopNode) *SopNodeDeleteOne {
  1709. return c.DeleteOneID(sn.ID)
  1710. }
  1711. // DeleteOneID returns a builder for deleting the given entity by its id.
  1712. func (c *SopNodeClient) DeleteOneID(id uint64) *SopNodeDeleteOne {
  1713. builder := c.Delete().Where(sopnode.ID(id))
  1714. builder.mutation.id = &id
  1715. builder.mutation.op = OpDeleteOne
  1716. return &SopNodeDeleteOne{builder}
  1717. }
  1718. // Query returns a query builder for SopNode.
  1719. func (c *SopNodeClient) Query() *SopNodeQuery {
  1720. return &SopNodeQuery{
  1721. config: c.config,
  1722. ctx: &QueryContext{Type: TypeSopNode},
  1723. inters: c.Interceptors(),
  1724. }
  1725. }
  1726. // Get returns a SopNode entity by its id.
  1727. func (c *SopNodeClient) Get(ctx context.Context, id uint64) (*SopNode, error) {
  1728. return c.Query().Where(sopnode.ID(id)).Only(ctx)
  1729. }
  1730. // GetX is like Get, but panics if an error occurs.
  1731. func (c *SopNodeClient) GetX(ctx context.Context, id uint64) *SopNode {
  1732. obj, err := c.Get(ctx, id)
  1733. if err != nil {
  1734. panic(err)
  1735. }
  1736. return obj
  1737. }
  1738. // QuerySopStage queries the sop_stage edge of a SopNode.
  1739. func (c *SopNodeClient) QuerySopStage(sn *SopNode) *SopStageQuery {
  1740. query := (&SopStageClient{config: c.config}).Query()
  1741. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1742. id := sn.ID
  1743. step := sqlgraph.NewStep(
  1744. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  1745. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  1746. sqlgraph.Edge(sqlgraph.M2O, true, sopnode.SopStageTable, sopnode.SopStageColumn),
  1747. )
  1748. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  1749. return fromV, nil
  1750. }
  1751. return query
  1752. }
  1753. // QueryNodeMessages queries the node_messages edge of a SopNode.
  1754. func (c *SopNodeClient) QueryNodeMessages(sn *SopNode) *MessageRecordsQuery {
  1755. query := (&MessageRecordsClient{config: c.config}).Query()
  1756. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1757. id := sn.ID
  1758. step := sqlgraph.NewStep(
  1759. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  1760. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  1761. sqlgraph.Edge(sqlgraph.O2M, false, sopnode.NodeMessagesTable, sopnode.NodeMessagesColumn),
  1762. )
  1763. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  1764. return fromV, nil
  1765. }
  1766. return query
  1767. }
  1768. // Hooks returns the client hooks.
  1769. func (c *SopNodeClient) Hooks() []Hook {
  1770. hooks := c.hooks.SopNode
  1771. return append(hooks[:len(hooks):len(hooks)], sopnode.Hooks[:]...)
  1772. }
  1773. // Interceptors returns the client interceptors.
  1774. func (c *SopNodeClient) Interceptors() []Interceptor {
  1775. inters := c.inters.SopNode
  1776. return append(inters[:len(inters):len(inters)], sopnode.Interceptors[:]...)
  1777. }
  1778. func (c *SopNodeClient) mutate(ctx context.Context, m *SopNodeMutation) (Value, error) {
  1779. switch m.Op() {
  1780. case OpCreate:
  1781. return (&SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1782. case OpUpdate:
  1783. return (&SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1784. case OpUpdateOne:
  1785. return (&SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1786. case OpDelete, OpDeleteOne:
  1787. return (&SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1788. default:
  1789. return nil, fmt.Errorf("ent: unknown SopNode mutation op: %q", m.Op())
  1790. }
  1791. }
  1792. // SopStageClient is a client for the SopStage schema.
  1793. type SopStageClient struct {
  1794. config
  1795. }
  1796. // NewSopStageClient returns a client for the SopStage from the given config.
  1797. func NewSopStageClient(c config) *SopStageClient {
  1798. return &SopStageClient{config: c}
  1799. }
  1800. // Use adds a list of mutation hooks to the hooks stack.
  1801. // A call to `Use(f, g, h)` equals to `sopstage.Hooks(f(g(h())))`.
  1802. func (c *SopStageClient) Use(hooks ...Hook) {
  1803. c.hooks.SopStage = append(c.hooks.SopStage, hooks...)
  1804. }
  1805. // Intercept adds a list of query interceptors to the interceptors stack.
  1806. // A call to `Intercept(f, g, h)` equals to `sopstage.Intercept(f(g(h())))`.
  1807. func (c *SopStageClient) Intercept(interceptors ...Interceptor) {
  1808. c.inters.SopStage = append(c.inters.SopStage, interceptors...)
  1809. }
  1810. // Create returns a builder for creating a SopStage entity.
  1811. func (c *SopStageClient) Create() *SopStageCreate {
  1812. mutation := newSopStageMutation(c.config, OpCreate)
  1813. return &SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1814. }
  1815. // CreateBulk returns a builder for creating a bulk of SopStage entities.
  1816. func (c *SopStageClient) CreateBulk(builders ...*SopStageCreate) *SopStageCreateBulk {
  1817. return &SopStageCreateBulk{config: c.config, builders: builders}
  1818. }
  1819. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1820. // a builder and applies setFunc on it.
  1821. func (c *SopStageClient) MapCreateBulk(slice any, setFunc func(*SopStageCreate, int)) *SopStageCreateBulk {
  1822. rv := reflect.ValueOf(slice)
  1823. if rv.Kind() != reflect.Slice {
  1824. return &SopStageCreateBulk{err: fmt.Errorf("calling to SopStageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1825. }
  1826. builders := make([]*SopStageCreate, rv.Len())
  1827. for i := 0; i < rv.Len(); i++ {
  1828. builders[i] = c.Create()
  1829. setFunc(builders[i], i)
  1830. }
  1831. return &SopStageCreateBulk{config: c.config, builders: builders}
  1832. }
  1833. // Update returns an update builder for SopStage.
  1834. func (c *SopStageClient) Update() *SopStageUpdate {
  1835. mutation := newSopStageMutation(c.config, OpUpdate)
  1836. return &SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1837. }
  1838. // UpdateOne returns an update builder for the given entity.
  1839. func (c *SopStageClient) UpdateOne(ss *SopStage) *SopStageUpdateOne {
  1840. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStage(ss))
  1841. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1842. }
  1843. // UpdateOneID returns an update builder for the given id.
  1844. func (c *SopStageClient) UpdateOneID(id uint64) *SopStageUpdateOne {
  1845. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStageID(id))
  1846. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1847. }
  1848. // Delete returns a delete builder for SopStage.
  1849. func (c *SopStageClient) Delete() *SopStageDelete {
  1850. mutation := newSopStageMutation(c.config, OpDelete)
  1851. return &SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1852. }
  1853. // DeleteOne returns a builder for deleting the given entity.
  1854. func (c *SopStageClient) DeleteOne(ss *SopStage) *SopStageDeleteOne {
  1855. return c.DeleteOneID(ss.ID)
  1856. }
  1857. // DeleteOneID returns a builder for deleting the given entity by its id.
  1858. func (c *SopStageClient) DeleteOneID(id uint64) *SopStageDeleteOne {
  1859. builder := c.Delete().Where(sopstage.ID(id))
  1860. builder.mutation.id = &id
  1861. builder.mutation.op = OpDeleteOne
  1862. return &SopStageDeleteOne{builder}
  1863. }
  1864. // Query returns a query builder for SopStage.
  1865. func (c *SopStageClient) Query() *SopStageQuery {
  1866. return &SopStageQuery{
  1867. config: c.config,
  1868. ctx: &QueryContext{Type: TypeSopStage},
  1869. inters: c.Interceptors(),
  1870. }
  1871. }
  1872. // Get returns a SopStage entity by its id.
  1873. func (c *SopStageClient) Get(ctx context.Context, id uint64) (*SopStage, error) {
  1874. return c.Query().Where(sopstage.ID(id)).Only(ctx)
  1875. }
  1876. // GetX is like Get, but panics if an error occurs.
  1877. func (c *SopStageClient) GetX(ctx context.Context, id uint64) *SopStage {
  1878. obj, err := c.Get(ctx, id)
  1879. if err != nil {
  1880. panic(err)
  1881. }
  1882. return obj
  1883. }
  1884. // QuerySopTask queries the sop_task edge of a SopStage.
  1885. func (c *SopStageClient) QuerySopTask(ss *SopStage) *SopTaskQuery {
  1886. query := (&SopTaskClient{config: c.config}).Query()
  1887. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1888. id := ss.ID
  1889. step := sqlgraph.NewStep(
  1890. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1891. sqlgraph.To(soptask.Table, soptask.FieldID),
  1892. sqlgraph.Edge(sqlgraph.M2O, true, sopstage.SopTaskTable, sopstage.SopTaskColumn),
  1893. )
  1894. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1895. return fromV, nil
  1896. }
  1897. return query
  1898. }
  1899. // QueryStageNodes queries the stage_nodes edge of a SopStage.
  1900. func (c *SopStageClient) QueryStageNodes(ss *SopStage) *SopNodeQuery {
  1901. query := (&SopNodeClient{config: c.config}).Query()
  1902. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1903. id := ss.ID
  1904. step := sqlgraph.NewStep(
  1905. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1906. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  1907. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageNodesTable, sopstage.StageNodesColumn),
  1908. )
  1909. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1910. return fromV, nil
  1911. }
  1912. return query
  1913. }
  1914. // QueryStageMessages queries the stage_messages edge of a SopStage.
  1915. func (c *SopStageClient) QueryStageMessages(ss *SopStage) *MessageRecordsQuery {
  1916. query := (&MessageRecordsClient{config: c.config}).Query()
  1917. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1918. id := ss.ID
  1919. step := sqlgraph.NewStep(
  1920. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1921. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  1922. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageMessagesTable, sopstage.StageMessagesColumn),
  1923. )
  1924. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1925. return fromV, nil
  1926. }
  1927. return query
  1928. }
  1929. // Hooks returns the client hooks.
  1930. func (c *SopStageClient) Hooks() []Hook {
  1931. hooks := c.hooks.SopStage
  1932. return append(hooks[:len(hooks):len(hooks)], sopstage.Hooks[:]...)
  1933. }
  1934. // Interceptors returns the client interceptors.
  1935. func (c *SopStageClient) Interceptors() []Interceptor {
  1936. inters := c.inters.SopStage
  1937. return append(inters[:len(inters):len(inters)], sopstage.Interceptors[:]...)
  1938. }
  1939. func (c *SopStageClient) mutate(ctx context.Context, m *SopStageMutation) (Value, error) {
  1940. switch m.Op() {
  1941. case OpCreate:
  1942. return (&SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1943. case OpUpdate:
  1944. return (&SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1945. case OpUpdateOne:
  1946. return (&SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1947. case OpDelete, OpDeleteOne:
  1948. return (&SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1949. default:
  1950. return nil, fmt.Errorf("ent: unknown SopStage mutation op: %q", m.Op())
  1951. }
  1952. }
  1953. // SopTaskClient is a client for the SopTask schema.
  1954. type SopTaskClient struct {
  1955. config
  1956. }
  1957. // NewSopTaskClient returns a client for the SopTask from the given config.
  1958. func NewSopTaskClient(c config) *SopTaskClient {
  1959. return &SopTaskClient{config: c}
  1960. }
  1961. // Use adds a list of mutation hooks to the hooks stack.
  1962. // A call to `Use(f, g, h)` equals to `soptask.Hooks(f(g(h())))`.
  1963. func (c *SopTaskClient) Use(hooks ...Hook) {
  1964. c.hooks.SopTask = append(c.hooks.SopTask, hooks...)
  1965. }
  1966. // Intercept adds a list of query interceptors to the interceptors stack.
  1967. // A call to `Intercept(f, g, h)` equals to `soptask.Intercept(f(g(h())))`.
  1968. func (c *SopTaskClient) Intercept(interceptors ...Interceptor) {
  1969. c.inters.SopTask = append(c.inters.SopTask, interceptors...)
  1970. }
  1971. // Create returns a builder for creating a SopTask entity.
  1972. func (c *SopTaskClient) Create() *SopTaskCreate {
  1973. mutation := newSopTaskMutation(c.config, OpCreate)
  1974. return &SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1975. }
  1976. // CreateBulk returns a builder for creating a bulk of SopTask entities.
  1977. func (c *SopTaskClient) CreateBulk(builders ...*SopTaskCreate) *SopTaskCreateBulk {
  1978. return &SopTaskCreateBulk{config: c.config, builders: builders}
  1979. }
  1980. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1981. // a builder and applies setFunc on it.
  1982. func (c *SopTaskClient) MapCreateBulk(slice any, setFunc func(*SopTaskCreate, int)) *SopTaskCreateBulk {
  1983. rv := reflect.ValueOf(slice)
  1984. if rv.Kind() != reflect.Slice {
  1985. return &SopTaskCreateBulk{err: fmt.Errorf("calling to SopTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1986. }
  1987. builders := make([]*SopTaskCreate, rv.Len())
  1988. for i := 0; i < rv.Len(); i++ {
  1989. builders[i] = c.Create()
  1990. setFunc(builders[i], i)
  1991. }
  1992. return &SopTaskCreateBulk{config: c.config, builders: builders}
  1993. }
  1994. // Update returns an update builder for SopTask.
  1995. func (c *SopTaskClient) Update() *SopTaskUpdate {
  1996. mutation := newSopTaskMutation(c.config, OpUpdate)
  1997. return &SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1998. }
  1999. // UpdateOne returns an update builder for the given entity.
  2000. func (c *SopTaskClient) UpdateOne(st *SopTask) *SopTaskUpdateOne {
  2001. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTask(st))
  2002. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2003. }
  2004. // UpdateOneID returns an update builder for the given id.
  2005. func (c *SopTaskClient) UpdateOneID(id uint64) *SopTaskUpdateOne {
  2006. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTaskID(id))
  2007. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2008. }
  2009. // Delete returns a delete builder for SopTask.
  2010. func (c *SopTaskClient) Delete() *SopTaskDelete {
  2011. mutation := newSopTaskMutation(c.config, OpDelete)
  2012. return &SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2013. }
  2014. // DeleteOne returns a builder for deleting the given entity.
  2015. func (c *SopTaskClient) DeleteOne(st *SopTask) *SopTaskDeleteOne {
  2016. return c.DeleteOneID(st.ID)
  2017. }
  2018. // DeleteOneID returns a builder for deleting the given entity by its id.
  2019. func (c *SopTaskClient) DeleteOneID(id uint64) *SopTaskDeleteOne {
  2020. builder := c.Delete().Where(soptask.ID(id))
  2021. builder.mutation.id = &id
  2022. builder.mutation.op = OpDeleteOne
  2023. return &SopTaskDeleteOne{builder}
  2024. }
  2025. // Query returns a query builder for SopTask.
  2026. func (c *SopTaskClient) Query() *SopTaskQuery {
  2027. return &SopTaskQuery{
  2028. config: c.config,
  2029. ctx: &QueryContext{Type: TypeSopTask},
  2030. inters: c.Interceptors(),
  2031. }
  2032. }
  2033. // Get returns a SopTask entity by its id.
  2034. func (c *SopTaskClient) Get(ctx context.Context, id uint64) (*SopTask, error) {
  2035. return c.Query().Where(soptask.ID(id)).Only(ctx)
  2036. }
  2037. // GetX is like Get, but panics if an error occurs.
  2038. func (c *SopTaskClient) GetX(ctx context.Context, id uint64) *SopTask {
  2039. obj, err := c.Get(ctx, id)
  2040. if err != nil {
  2041. panic(err)
  2042. }
  2043. return obj
  2044. }
  2045. // QueryTaskStages queries the task_stages edge of a SopTask.
  2046. func (c *SopTaskClient) QueryTaskStages(st *SopTask) *SopStageQuery {
  2047. query := (&SopStageClient{config: c.config}).Query()
  2048. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2049. id := st.ID
  2050. step := sqlgraph.NewStep(
  2051. sqlgraph.From(soptask.Table, soptask.FieldID, id),
  2052. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2053. sqlgraph.Edge(sqlgraph.O2M, false, soptask.TaskStagesTable, soptask.TaskStagesColumn),
  2054. )
  2055. fromV = sqlgraph.Neighbors(st.driver.Dialect(), step)
  2056. return fromV, nil
  2057. }
  2058. return query
  2059. }
  2060. // Hooks returns the client hooks.
  2061. func (c *SopTaskClient) Hooks() []Hook {
  2062. hooks := c.hooks.SopTask
  2063. return append(hooks[:len(hooks):len(hooks)], soptask.Hooks[:]...)
  2064. }
  2065. // Interceptors returns the client interceptors.
  2066. func (c *SopTaskClient) Interceptors() []Interceptor {
  2067. inters := c.inters.SopTask
  2068. return append(inters[:len(inters):len(inters)], soptask.Interceptors[:]...)
  2069. }
  2070. func (c *SopTaskClient) mutate(ctx context.Context, m *SopTaskMutation) (Value, error) {
  2071. switch m.Op() {
  2072. case OpCreate:
  2073. return (&SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2074. case OpUpdate:
  2075. return (&SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2076. case OpUpdateOne:
  2077. return (&SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2078. case OpDelete, OpDeleteOne:
  2079. return (&SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2080. default:
  2081. return nil, fmt.Errorf("ent: unknown SopTask mutation op: %q", m.Op())
  2082. }
  2083. }
  2084. // TutorialClient is a client for the Tutorial schema.
  2085. type TutorialClient struct {
  2086. config
  2087. }
  2088. // NewTutorialClient returns a client for the Tutorial from the given config.
  2089. func NewTutorialClient(c config) *TutorialClient {
  2090. return &TutorialClient{config: c}
  2091. }
  2092. // Use adds a list of mutation hooks to the hooks stack.
  2093. // A call to `Use(f, g, h)` equals to `tutorial.Hooks(f(g(h())))`.
  2094. func (c *TutorialClient) Use(hooks ...Hook) {
  2095. c.hooks.Tutorial = append(c.hooks.Tutorial, hooks...)
  2096. }
  2097. // Intercept adds a list of query interceptors to the interceptors stack.
  2098. // A call to `Intercept(f, g, h)` equals to `tutorial.Intercept(f(g(h())))`.
  2099. func (c *TutorialClient) Intercept(interceptors ...Interceptor) {
  2100. c.inters.Tutorial = append(c.inters.Tutorial, interceptors...)
  2101. }
  2102. // Create returns a builder for creating a Tutorial entity.
  2103. func (c *TutorialClient) Create() *TutorialCreate {
  2104. mutation := newTutorialMutation(c.config, OpCreate)
  2105. return &TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2106. }
  2107. // CreateBulk returns a builder for creating a bulk of Tutorial entities.
  2108. func (c *TutorialClient) CreateBulk(builders ...*TutorialCreate) *TutorialCreateBulk {
  2109. return &TutorialCreateBulk{config: c.config, builders: builders}
  2110. }
  2111. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2112. // a builder and applies setFunc on it.
  2113. func (c *TutorialClient) MapCreateBulk(slice any, setFunc func(*TutorialCreate, int)) *TutorialCreateBulk {
  2114. rv := reflect.ValueOf(slice)
  2115. if rv.Kind() != reflect.Slice {
  2116. return &TutorialCreateBulk{err: fmt.Errorf("calling to TutorialClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2117. }
  2118. builders := make([]*TutorialCreate, rv.Len())
  2119. for i := 0; i < rv.Len(); i++ {
  2120. builders[i] = c.Create()
  2121. setFunc(builders[i], i)
  2122. }
  2123. return &TutorialCreateBulk{config: c.config, builders: builders}
  2124. }
  2125. // Update returns an update builder for Tutorial.
  2126. func (c *TutorialClient) Update() *TutorialUpdate {
  2127. mutation := newTutorialMutation(c.config, OpUpdate)
  2128. return &TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2129. }
  2130. // UpdateOne returns an update builder for the given entity.
  2131. func (c *TutorialClient) UpdateOne(t *Tutorial) *TutorialUpdateOne {
  2132. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorial(t))
  2133. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2134. }
  2135. // UpdateOneID returns an update builder for the given id.
  2136. func (c *TutorialClient) UpdateOneID(id uint64) *TutorialUpdateOne {
  2137. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorialID(id))
  2138. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2139. }
  2140. // Delete returns a delete builder for Tutorial.
  2141. func (c *TutorialClient) Delete() *TutorialDelete {
  2142. mutation := newTutorialMutation(c.config, OpDelete)
  2143. return &TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2144. }
  2145. // DeleteOne returns a builder for deleting the given entity.
  2146. func (c *TutorialClient) DeleteOne(t *Tutorial) *TutorialDeleteOne {
  2147. return c.DeleteOneID(t.ID)
  2148. }
  2149. // DeleteOneID returns a builder for deleting the given entity by its id.
  2150. func (c *TutorialClient) DeleteOneID(id uint64) *TutorialDeleteOne {
  2151. builder := c.Delete().Where(tutorial.ID(id))
  2152. builder.mutation.id = &id
  2153. builder.mutation.op = OpDeleteOne
  2154. return &TutorialDeleteOne{builder}
  2155. }
  2156. // Query returns a query builder for Tutorial.
  2157. func (c *TutorialClient) Query() *TutorialQuery {
  2158. return &TutorialQuery{
  2159. config: c.config,
  2160. ctx: &QueryContext{Type: TypeTutorial},
  2161. inters: c.Interceptors(),
  2162. }
  2163. }
  2164. // Get returns a Tutorial entity by its id.
  2165. func (c *TutorialClient) Get(ctx context.Context, id uint64) (*Tutorial, error) {
  2166. return c.Query().Where(tutorial.ID(id)).Only(ctx)
  2167. }
  2168. // GetX is like Get, but panics if an error occurs.
  2169. func (c *TutorialClient) GetX(ctx context.Context, id uint64) *Tutorial {
  2170. obj, err := c.Get(ctx, id)
  2171. if err != nil {
  2172. panic(err)
  2173. }
  2174. return obj
  2175. }
  2176. // QueryEmployee queries the employee edge of a Tutorial.
  2177. func (c *TutorialClient) QueryEmployee(t *Tutorial) *EmployeeQuery {
  2178. query := (&EmployeeClient{config: c.config}).Query()
  2179. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2180. id := t.ID
  2181. step := sqlgraph.NewStep(
  2182. sqlgraph.From(tutorial.Table, tutorial.FieldID, id),
  2183. sqlgraph.To(employee.Table, employee.FieldID),
  2184. sqlgraph.Edge(sqlgraph.M2O, true, tutorial.EmployeeTable, tutorial.EmployeeColumn),
  2185. )
  2186. fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
  2187. return fromV, nil
  2188. }
  2189. return query
  2190. }
  2191. // Hooks returns the client hooks.
  2192. func (c *TutorialClient) Hooks() []Hook {
  2193. hooks := c.hooks.Tutorial
  2194. return append(hooks[:len(hooks):len(hooks)], tutorial.Hooks[:]...)
  2195. }
  2196. // Interceptors returns the client interceptors.
  2197. func (c *TutorialClient) Interceptors() []Interceptor {
  2198. inters := c.inters.Tutorial
  2199. return append(inters[:len(inters):len(inters)], tutorial.Interceptors[:]...)
  2200. }
  2201. func (c *TutorialClient) mutate(ctx context.Context, m *TutorialMutation) (Value, error) {
  2202. switch m.Op() {
  2203. case OpCreate:
  2204. return (&TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2205. case OpUpdate:
  2206. return (&TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2207. case OpUpdateOne:
  2208. return (&TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2209. case OpDelete, OpDeleteOne:
  2210. return (&TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2211. default:
  2212. return nil, fmt.Errorf("ent: unknown Tutorial mutation op: %q", m.Op())
  2213. }
  2214. }
  2215. // WorkExperienceClient is a client for the WorkExperience schema.
  2216. type WorkExperienceClient struct {
  2217. config
  2218. }
  2219. // NewWorkExperienceClient returns a client for the WorkExperience from the given config.
  2220. func NewWorkExperienceClient(c config) *WorkExperienceClient {
  2221. return &WorkExperienceClient{config: c}
  2222. }
  2223. // Use adds a list of mutation hooks to the hooks stack.
  2224. // A call to `Use(f, g, h)` equals to `workexperience.Hooks(f(g(h())))`.
  2225. func (c *WorkExperienceClient) Use(hooks ...Hook) {
  2226. c.hooks.WorkExperience = append(c.hooks.WorkExperience, hooks...)
  2227. }
  2228. // Intercept adds a list of query interceptors to the interceptors stack.
  2229. // A call to `Intercept(f, g, h)` equals to `workexperience.Intercept(f(g(h())))`.
  2230. func (c *WorkExperienceClient) Intercept(interceptors ...Interceptor) {
  2231. c.inters.WorkExperience = append(c.inters.WorkExperience, interceptors...)
  2232. }
  2233. // Create returns a builder for creating a WorkExperience entity.
  2234. func (c *WorkExperienceClient) Create() *WorkExperienceCreate {
  2235. mutation := newWorkExperienceMutation(c.config, OpCreate)
  2236. return &WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2237. }
  2238. // CreateBulk returns a builder for creating a bulk of WorkExperience entities.
  2239. func (c *WorkExperienceClient) CreateBulk(builders ...*WorkExperienceCreate) *WorkExperienceCreateBulk {
  2240. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  2241. }
  2242. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2243. // a builder and applies setFunc on it.
  2244. func (c *WorkExperienceClient) MapCreateBulk(slice any, setFunc func(*WorkExperienceCreate, int)) *WorkExperienceCreateBulk {
  2245. rv := reflect.ValueOf(slice)
  2246. if rv.Kind() != reflect.Slice {
  2247. return &WorkExperienceCreateBulk{err: fmt.Errorf("calling to WorkExperienceClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2248. }
  2249. builders := make([]*WorkExperienceCreate, rv.Len())
  2250. for i := 0; i < rv.Len(); i++ {
  2251. builders[i] = c.Create()
  2252. setFunc(builders[i], i)
  2253. }
  2254. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  2255. }
  2256. // Update returns an update builder for WorkExperience.
  2257. func (c *WorkExperienceClient) Update() *WorkExperienceUpdate {
  2258. mutation := newWorkExperienceMutation(c.config, OpUpdate)
  2259. return &WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2260. }
  2261. // UpdateOne returns an update builder for the given entity.
  2262. func (c *WorkExperienceClient) UpdateOne(we *WorkExperience) *WorkExperienceUpdateOne {
  2263. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperience(we))
  2264. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2265. }
  2266. // UpdateOneID returns an update builder for the given id.
  2267. func (c *WorkExperienceClient) UpdateOneID(id uint64) *WorkExperienceUpdateOne {
  2268. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperienceID(id))
  2269. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2270. }
  2271. // Delete returns a delete builder for WorkExperience.
  2272. func (c *WorkExperienceClient) Delete() *WorkExperienceDelete {
  2273. mutation := newWorkExperienceMutation(c.config, OpDelete)
  2274. return &WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2275. }
  2276. // DeleteOne returns a builder for deleting the given entity.
  2277. func (c *WorkExperienceClient) DeleteOne(we *WorkExperience) *WorkExperienceDeleteOne {
  2278. return c.DeleteOneID(we.ID)
  2279. }
  2280. // DeleteOneID returns a builder for deleting the given entity by its id.
  2281. func (c *WorkExperienceClient) DeleteOneID(id uint64) *WorkExperienceDeleteOne {
  2282. builder := c.Delete().Where(workexperience.ID(id))
  2283. builder.mutation.id = &id
  2284. builder.mutation.op = OpDeleteOne
  2285. return &WorkExperienceDeleteOne{builder}
  2286. }
  2287. // Query returns a query builder for WorkExperience.
  2288. func (c *WorkExperienceClient) Query() *WorkExperienceQuery {
  2289. return &WorkExperienceQuery{
  2290. config: c.config,
  2291. ctx: &QueryContext{Type: TypeWorkExperience},
  2292. inters: c.Interceptors(),
  2293. }
  2294. }
  2295. // Get returns a WorkExperience entity by its id.
  2296. func (c *WorkExperienceClient) Get(ctx context.Context, id uint64) (*WorkExperience, error) {
  2297. return c.Query().Where(workexperience.ID(id)).Only(ctx)
  2298. }
  2299. // GetX is like Get, but panics if an error occurs.
  2300. func (c *WorkExperienceClient) GetX(ctx context.Context, id uint64) *WorkExperience {
  2301. obj, err := c.Get(ctx, id)
  2302. if err != nil {
  2303. panic(err)
  2304. }
  2305. return obj
  2306. }
  2307. // QueryEmployee queries the employee edge of a WorkExperience.
  2308. func (c *WorkExperienceClient) QueryEmployee(we *WorkExperience) *EmployeeQuery {
  2309. query := (&EmployeeClient{config: c.config}).Query()
  2310. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2311. id := we.ID
  2312. step := sqlgraph.NewStep(
  2313. sqlgraph.From(workexperience.Table, workexperience.FieldID, id),
  2314. sqlgraph.To(employee.Table, employee.FieldID),
  2315. sqlgraph.Edge(sqlgraph.M2O, true, workexperience.EmployeeTable, workexperience.EmployeeColumn),
  2316. )
  2317. fromV = sqlgraph.Neighbors(we.driver.Dialect(), step)
  2318. return fromV, nil
  2319. }
  2320. return query
  2321. }
  2322. // Hooks returns the client hooks.
  2323. func (c *WorkExperienceClient) Hooks() []Hook {
  2324. hooks := c.hooks.WorkExperience
  2325. return append(hooks[:len(hooks):len(hooks)], workexperience.Hooks[:]...)
  2326. }
  2327. // Interceptors returns the client interceptors.
  2328. func (c *WorkExperienceClient) Interceptors() []Interceptor {
  2329. inters := c.inters.WorkExperience
  2330. return append(inters[:len(inters):len(inters)], workexperience.Interceptors[:]...)
  2331. }
  2332. func (c *WorkExperienceClient) mutate(ctx context.Context, m *WorkExperienceMutation) (Value, error) {
  2333. switch m.Op() {
  2334. case OpCreate:
  2335. return (&WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2336. case OpUpdate:
  2337. return (&WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2338. case OpUpdateOne:
  2339. return (&WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2340. case OpDelete, OpDeleteOne:
  2341. return (&WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2342. default:
  2343. return nil, fmt.Errorf("ent: unknown WorkExperience mutation op: %q", m.Op())
  2344. }
  2345. }
  2346. // WxClient is a client for the Wx schema.
  2347. type WxClient struct {
  2348. config
  2349. }
  2350. // NewWxClient returns a client for the Wx from the given config.
  2351. func NewWxClient(c config) *WxClient {
  2352. return &WxClient{config: c}
  2353. }
  2354. // Use adds a list of mutation hooks to the hooks stack.
  2355. // A call to `Use(f, g, h)` equals to `wx.Hooks(f(g(h())))`.
  2356. func (c *WxClient) Use(hooks ...Hook) {
  2357. c.hooks.Wx = append(c.hooks.Wx, hooks...)
  2358. }
  2359. // Intercept adds a list of query interceptors to the interceptors stack.
  2360. // A call to `Intercept(f, g, h)` equals to `wx.Intercept(f(g(h())))`.
  2361. func (c *WxClient) Intercept(interceptors ...Interceptor) {
  2362. c.inters.Wx = append(c.inters.Wx, interceptors...)
  2363. }
  2364. // Create returns a builder for creating a Wx entity.
  2365. func (c *WxClient) Create() *WxCreate {
  2366. mutation := newWxMutation(c.config, OpCreate)
  2367. return &WxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2368. }
  2369. // CreateBulk returns a builder for creating a bulk of Wx entities.
  2370. func (c *WxClient) CreateBulk(builders ...*WxCreate) *WxCreateBulk {
  2371. return &WxCreateBulk{config: c.config, builders: builders}
  2372. }
  2373. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2374. // a builder and applies setFunc on it.
  2375. func (c *WxClient) MapCreateBulk(slice any, setFunc func(*WxCreate, int)) *WxCreateBulk {
  2376. rv := reflect.ValueOf(slice)
  2377. if rv.Kind() != reflect.Slice {
  2378. return &WxCreateBulk{err: fmt.Errorf("calling to WxClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2379. }
  2380. builders := make([]*WxCreate, rv.Len())
  2381. for i := 0; i < rv.Len(); i++ {
  2382. builders[i] = c.Create()
  2383. setFunc(builders[i], i)
  2384. }
  2385. return &WxCreateBulk{config: c.config, builders: builders}
  2386. }
  2387. // Update returns an update builder for Wx.
  2388. func (c *WxClient) Update() *WxUpdate {
  2389. mutation := newWxMutation(c.config, OpUpdate)
  2390. return &WxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2391. }
  2392. // UpdateOne returns an update builder for the given entity.
  2393. func (c *WxClient) UpdateOne(w *Wx) *WxUpdateOne {
  2394. mutation := newWxMutation(c.config, OpUpdateOne, withWx(w))
  2395. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2396. }
  2397. // UpdateOneID returns an update builder for the given id.
  2398. func (c *WxClient) UpdateOneID(id uint64) *WxUpdateOne {
  2399. mutation := newWxMutation(c.config, OpUpdateOne, withWxID(id))
  2400. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2401. }
  2402. // Delete returns a delete builder for Wx.
  2403. func (c *WxClient) Delete() *WxDelete {
  2404. mutation := newWxMutation(c.config, OpDelete)
  2405. return &WxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2406. }
  2407. // DeleteOne returns a builder for deleting the given entity.
  2408. func (c *WxClient) DeleteOne(w *Wx) *WxDeleteOne {
  2409. return c.DeleteOneID(w.ID)
  2410. }
  2411. // DeleteOneID returns a builder for deleting the given entity by its id.
  2412. func (c *WxClient) DeleteOneID(id uint64) *WxDeleteOne {
  2413. builder := c.Delete().Where(wx.ID(id))
  2414. builder.mutation.id = &id
  2415. builder.mutation.op = OpDeleteOne
  2416. return &WxDeleteOne{builder}
  2417. }
  2418. // Query returns a query builder for Wx.
  2419. func (c *WxClient) Query() *WxQuery {
  2420. return &WxQuery{
  2421. config: c.config,
  2422. ctx: &QueryContext{Type: TypeWx},
  2423. inters: c.Interceptors(),
  2424. }
  2425. }
  2426. // Get returns a Wx entity by its id.
  2427. func (c *WxClient) Get(ctx context.Context, id uint64) (*Wx, error) {
  2428. return c.Query().Where(wx.ID(id)).Only(ctx)
  2429. }
  2430. // GetX is like Get, but panics if an error occurs.
  2431. func (c *WxClient) GetX(ctx context.Context, id uint64) *Wx {
  2432. obj, err := c.Get(ctx, id)
  2433. if err != nil {
  2434. panic(err)
  2435. }
  2436. return obj
  2437. }
  2438. // QueryServer queries the server edge of a Wx.
  2439. func (c *WxClient) QueryServer(w *Wx) *ServerQuery {
  2440. query := (&ServerClient{config: c.config}).Query()
  2441. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2442. id := w.ID
  2443. step := sqlgraph.NewStep(
  2444. sqlgraph.From(wx.Table, wx.FieldID, id),
  2445. sqlgraph.To(server.Table, server.FieldID),
  2446. sqlgraph.Edge(sqlgraph.M2O, true, wx.ServerTable, wx.ServerColumn),
  2447. )
  2448. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  2449. return fromV, nil
  2450. }
  2451. return query
  2452. }
  2453. // QueryAgent queries the agent edge of a Wx.
  2454. func (c *WxClient) QueryAgent(w *Wx) *AgentQuery {
  2455. query := (&AgentClient{config: c.config}).Query()
  2456. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2457. id := w.ID
  2458. step := sqlgraph.NewStep(
  2459. sqlgraph.From(wx.Table, wx.FieldID, id),
  2460. sqlgraph.To(agent.Table, agent.FieldID),
  2461. sqlgraph.Edge(sqlgraph.M2O, true, wx.AgentTable, wx.AgentColumn),
  2462. )
  2463. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  2464. return fromV, nil
  2465. }
  2466. return query
  2467. }
  2468. // Hooks returns the client hooks.
  2469. func (c *WxClient) Hooks() []Hook {
  2470. hooks := c.hooks.Wx
  2471. return append(hooks[:len(hooks):len(hooks)], wx.Hooks[:]...)
  2472. }
  2473. // Interceptors returns the client interceptors.
  2474. func (c *WxClient) Interceptors() []Interceptor {
  2475. inters := c.inters.Wx
  2476. return append(inters[:len(inters):len(inters)], wx.Interceptors[:]...)
  2477. }
  2478. func (c *WxClient) mutate(ctx context.Context, m *WxMutation) (Value, error) {
  2479. switch m.Op() {
  2480. case OpCreate:
  2481. return (&WxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2482. case OpUpdate:
  2483. return (&WxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2484. case OpUpdateOne:
  2485. return (&WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2486. case OpDelete, OpDeleteOne:
  2487. return (&WxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2488. default:
  2489. return nil, fmt.Errorf("ent: unknown Wx mutation op: %q", m.Op())
  2490. }
  2491. }
  2492. // hooks and interceptors per client, for fast access.
  2493. type (
  2494. hooks struct {
  2495. Agent, BatchMsg, Contact, Employee, Label, LabelRelationship, Message,
  2496. MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Tutorial,
  2497. WorkExperience, Wx []ent.Hook
  2498. }
  2499. inters struct {
  2500. Agent, BatchMsg, Contact, Employee, Label, LabelRelationship, Message,
  2501. MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Tutorial,
  2502. WorkExperience, Wx []ent.Interceptor
  2503. }
  2504. )
  2505. // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
  2506. // See, database/sql#DB.ExecContext for more information.
  2507. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
  2508. ex, ok := c.driver.(interface {
  2509. ExecContext(context.Context, string, ...any) (stdsql.Result, error)
  2510. })
  2511. if !ok {
  2512. return nil, fmt.Errorf("Driver.ExecContext is not supported")
  2513. }
  2514. return ex.ExecContext(ctx, query, args...)
  2515. }
  2516. // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
  2517. // See, database/sql#DB.QueryContext for more information.
  2518. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
  2519. q, ok := c.driver.(interface {
  2520. QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
  2521. })
  2522. if !ok {
  2523. return nil, fmt.Errorf("Driver.QueryContext is not supported")
  2524. }
  2525. return q.QueryContext(ctx, query, args...)
  2526. }