pendingauthsession_create.go 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
  12. "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
  13. "github.com/Wei-Shaw/sub2api/ent/user"
  14. )
  15. // PendingAuthSessionCreate is the builder for creating a PendingAuthSession entity.
  16. type PendingAuthSessionCreate struct {
  17. config
  18. mutation *PendingAuthSessionMutation
  19. hooks []Hook
  20. conflict []sql.ConflictOption
  21. }
  22. // SetCreatedAt sets the "created_at" field.
  23. func (_c *PendingAuthSessionCreate) SetCreatedAt(v time.Time) *PendingAuthSessionCreate {
  24. _c.mutation.SetCreatedAt(v)
  25. return _c
  26. }
  27. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  28. func (_c *PendingAuthSessionCreate) SetNillableCreatedAt(v *time.Time) *PendingAuthSessionCreate {
  29. if v != nil {
  30. _c.SetCreatedAt(*v)
  31. }
  32. return _c
  33. }
  34. // SetUpdatedAt sets the "updated_at" field.
  35. func (_c *PendingAuthSessionCreate) SetUpdatedAt(v time.Time) *PendingAuthSessionCreate {
  36. _c.mutation.SetUpdatedAt(v)
  37. return _c
  38. }
  39. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  40. func (_c *PendingAuthSessionCreate) SetNillableUpdatedAt(v *time.Time) *PendingAuthSessionCreate {
  41. if v != nil {
  42. _c.SetUpdatedAt(*v)
  43. }
  44. return _c
  45. }
  46. // SetSessionToken sets the "session_token" field.
  47. func (_c *PendingAuthSessionCreate) SetSessionToken(v string) *PendingAuthSessionCreate {
  48. _c.mutation.SetSessionToken(v)
  49. return _c
  50. }
  51. // SetIntent sets the "intent" field.
  52. func (_c *PendingAuthSessionCreate) SetIntent(v string) *PendingAuthSessionCreate {
  53. _c.mutation.SetIntent(v)
  54. return _c
  55. }
  56. // SetProviderType sets the "provider_type" field.
  57. func (_c *PendingAuthSessionCreate) SetProviderType(v string) *PendingAuthSessionCreate {
  58. _c.mutation.SetProviderType(v)
  59. return _c
  60. }
  61. // SetProviderKey sets the "provider_key" field.
  62. func (_c *PendingAuthSessionCreate) SetProviderKey(v string) *PendingAuthSessionCreate {
  63. _c.mutation.SetProviderKey(v)
  64. return _c
  65. }
  66. // SetProviderSubject sets the "provider_subject" field.
  67. func (_c *PendingAuthSessionCreate) SetProviderSubject(v string) *PendingAuthSessionCreate {
  68. _c.mutation.SetProviderSubject(v)
  69. return _c
  70. }
  71. // SetTargetUserID sets the "target_user_id" field.
  72. func (_c *PendingAuthSessionCreate) SetTargetUserID(v int64) *PendingAuthSessionCreate {
  73. _c.mutation.SetTargetUserID(v)
  74. return _c
  75. }
  76. // SetNillableTargetUserID sets the "target_user_id" field if the given value is not nil.
  77. func (_c *PendingAuthSessionCreate) SetNillableTargetUserID(v *int64) *PendingAuthSessionCreate {
  78. if v != nil {
  79. _c.SetTargetUserID(*v)
  80. }
  81. return _c
  82. }
  83. // SetRedirectTo sets the "redirect_to" field.
  84. func (_c *PendingAuthSessionCreate) SetRedirectTo(v string) *PendingAuthSessionCreate {
  85. _c.mutation.SetRedirectTo(v)
  86. return _c
  87. }
  88. // SetNillableRedirectTo sets the "redirect_to" field if the given value is not nil.
  89. func (_c *PendingAuthSessionCreate) SetNillableRedirectTo(v *string) *PendingAuthSessionCreate {
  90. if v != nil {
  91. _c.SetRedirectTo(*v)
  92. }
  93. return _c
  94. }
  95. // SetResolvedEmail sets the "resolved_email" field.
  96. func (_c *PendingAuthSessionCreate) SetResolvedEmail(v string) *PendingAuthSessionCreate {
  97. _c.mutation.SetResolvedEmail(v)
  98. return _c
  99. }
  100. // SetNillableResolvedEmail sets the "resolved_email" field if the given value is not nil.
  101. func (_c *PendingAuthSessionCreate) SetNillableResolvedEmail(v *string) *PendingAuthSessionCreate {
  102. if v != nil {
  103. _c.SetResolvedEmail(*v)
  104. }
  105. return _c
  106. }
  107. // SetRegistrationPasswordHash sets the "registration_password_hash" field.
  108. func (_c *PendingAuthSessionCreate) SetRegistrationPasswordHash(v string) *PendingAuthSessionCreate {
  109. _c.mutation.SetRegistrationPasswordHash(v)
  110. return _c
  111. }
  112. // SetNillableRegistrationPasswordHash sets the "registration_password_hash" field if the given value is not nil.
  113. func (_c *PendingAuthSessionCreate) SetNillableRegistrationPasswordHash(v *string) *PendingAuthSessionCreate {
  114. if v != nil {
  115. _c.SetRegistrationPasswordHash(*v)
  116. }
  117. return _c
  118. }
  119. // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
  120. func (_c *PendingAuthSessionCreate) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionCreate {
  121. _c.mutation.SetUpstreamIdentityClaims(v)
  122. return _c
  123. }
  124. // SetLocalFlowState sets the "local_flow_state" field.
  125. func (_c *PendingAuthSessionCreate) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionCreate {
  126. _c.mutation.SetLocalFlowState(v)
  127. return _c
  128. }
  129. // SetBrowserSessionKey sets the "browser_session_key" field.
  130. func (_c *PendingAuthSessionCreate) SetBrowserSessionKey(v string) *PendingAuthSessionCreate {
  131. _c.mutation.SetBrowserSessionKey(v)
  132. return _c
  133. }
  134. // SetNillableBrowserSessionKey sets the "browser_session_key" field if the given value is not nil.
  135. func (_c *PendingAuthSessionCreate) SetNillableBrowserSessionKey(v *string) *PendingAuthSessionCreate {
  136. if v != nil {
  137. _c.SetBrowserSessionKey(*v)
  138. }
  139. return _c
  140. }
  141. // SetCompletionCodeHash sets the "completion_code_hash" field.
  142. func (_c *PendingAuthSessionCreate) SetCompletionCodeHash(v string) *PendingAuthSessionCreate {
  143. _c.mutation.SetCompletionCodeHash(v)
  144. return _c
  145. }
  146. // SetNillableCompletionCodeHash sets the "completion_code_hash" field if the given value is not nil.
  147. func (_c *PendingAuthSessionCreate) SetNillableCompletionCodeHash(v *string) *PendingAuthSessionCreate {
  148. if v != nil {
  149. _c.SetCompletionCodeHash(*v)
  150. }
  151. return _c
  152. }
  153. // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
  154. func (_c *PendingAuthSessionCreate) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionCreate {
  155. _c.mutation.SetCompletionCodeExpiresAt(v)
  156. return _c
  157. }
  158. // SetNillableCompletionCodeExpiresAt sets the "completion_code_expires_at" field if the given value is not nil.
  159. func (_c *PendingAuthSessionCreate) SetNillableCompletionCodeExpiresAt(v *time.Time) *PendingAuthSessionCreate {
  160. if v != nil {
  161. _c.SetCompletionCodeExpiresAt(*v)
  162. }
  163. return _c
  164. }
  165. // SetEmailVerifiedAt sets the "email_verified_at" field.
  166. func (_c *PendingAuthSessionCreate) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionCreate {
  167. _c.mutation.SetEmailVerifiedAt(v)
  168. return _c
  169. }
  170. // SetNillableEmailVerifiedAt sets the "email_verified_at" field if the given value is not nil.
  171. func (_c *PendingAuthSessionCreate) SetNillableEmailVerifiedAt(v *time.Time) *PendingAuthSessionCreate {
  172. if v != nil {
  173. _c.SetEmailVerifiedAt(*v)
  174. }
  175. return _c
  176. }
  177. // SetPasswordVerifiedAt sets the "password_verified_at" field.
  178. func (_c *PendingAuthSessionCreate) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionCreate {
  179. _c.mutation.SetPasswordVerifiedAt(v)
  180. return _c
  181. }
  182. // SetNillablePasswordVerifiedAt sets the "password_verified_at" field if the given value is not nil.
  183. func (_c *PendingAuthSessionCreate) SetNillablePasswordVerifiedAt(v *time.Time) *PendingAuthSessionCreate {
  184. if v != nil {
  185. _c.SetPasswordVerifiedAt(*v)
  186. }
  187. return _c
  188. }
  189. // SetTotpVerifiedAt sets the "totp_verified_at" field.
  190. func (_c *PendingAuthSessionCreate) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionCreate {
  191. _c.mutation.SetTotpVerifiedAt(v)
  192. return _c
  193. }
  194. // SetNillableTotpVerifiedAt sets the "totp_verified_at" field if the given value is not nil.
  195. func (_c *PendingAuthSessionCreate) SetNillableTotpVerifiedAt(v *time.Time) *PendingAuthSessionCreate {
  196. if v != nil {
  197. _c.SetTotpVerifiedAt(*v)
  198. }
  199. return _c
  200. }
  201. // SetExpiresAt sets the "expires_at" field.
  202. func (_c *PendingAuthSessionCreate) SetExpiresAt(v time.Time) *PendingAuthSessionCreate {
  203. _c.mutation.SetExpiresAt(v)
  204. return _c
  205. }
  206. // SetConsumedAt sets the "consumed_at" field.
  207. func (_c *PendingAuthSessionCreate) SetConsumedAt(v time.Time) *PendingAuthSessionCreate {
  208. _c.mutation.SetConsumedAt(v)
  209. return _c
  210. }
  211. // SetNillableConsumedAt sets the "consumed_at" field if the given value is not nil.
  212. func (_c *PendingAuthSessionCreate) SetNillableConsumedAt(v *time.Time) *PendingAuthSessionCreate {
  213. if v != nil {
  214. _c.SetConsumedAt(*v)
  215. }
  216. return _c
  217. }
  218. // SetTargetUser sets the "target_user" edge to the User entity.
  219. func (_c *PendingAuthSessionCreate) SetTargetUser(v *User) *PendingAuthSessionCreate {
  220. return _c.SetTargetUserID(v.ID)
  221. }
  222. // SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID.
  223. func (_c *PendingAuthSessionCreate) SetAdoptionDecisionID(id int64) *PendingAuthSessionCreate {
  224. _c.mutation.SetAdoptionDecisionID(id)
  225. return _c
  226. }
  227. // SetNillableAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID if the given value is not nil.
  228. func (_c *PendingAuthSessionCreate) SetNillableAdoptionDecisionID(id *int64) *PendingAuthSessionCreate {
  229. if id != nil {
  230. _c = _c.SetAdoptionDecisionID(*id)
  231. }
  232. return _c
  233. }
  234. // SetAdoptionDecision sets the "adoption_decision" edge to the IdentityAdoptionDecision entity.
  235. func (_c *PendingAuthSessionCreate) SetAdoptionDecision(v *IdentityAdoptionDecision) *PendingAuthSessionCreate {
  236. return _c.SetAdoptionDecisionID(v.ID)
  237. }
  238. // Mutation returns the PendingAuthSessionMutation object of the builder.
  239. func (_c *PendingAuthSessionCreate) Mutation() *PendingAuthSessionMutation {
  240. return _c.mutation
  241. }
  242. // Save creates the PendingAuthSession in the database.
  243. func (_c *PendingAuthSessionCreate) Save(ctx context.Context) (*PendingAuthSession, error) {
  244. _c.defaults()
  245. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  246. }
  247. // SaveX calls Save and panics if Save returns an error.
  248. func (_c *PendingAuthSessionCreate) SaveX(ctx context.Context) *PendingAuthSession {
  249. v, err := _c.Save(ctx)
  250. if err != nil {
  251. panic(err)
  252. }
  253. return v
  254. }
  255. // Exec executes the query.
  256. func (_c *PendingAuthSessionCreate) Exec(ctx context.Context) error {
  257. _, err := _c.Save(ctx)
  258. return err
  259. }
  260. // ExecX is like Exec, but panics if an error occurs.
  261. func (_c *PendingAuthSessionCreate) ExecX(ctx context.Context) {
  262. if err := _c.Exec(ctx); err != nil {
  263. panic(err)
  264. }
  265. }
  266. // defaults sets the default values of the builder before save.
  267. func (_c *PendingAuthSessionCreate) defaults() {
  268. if _, ok := _c.mutation.CreatedAt(); !ok {
  269. v := pendingauthsession.DefaultCreatedAt()
  270. _c.mutation.SetCreatedAt(v)
  271. }
  272. if _, ok := _c.mutation.UpdatedAt(); !ok {
  273. v := pendingauthsession.DefaultUpdatedAt()
  274. _c.mutation.SetUpdatedAt(v)
  275. }
  276. if _, ok := _c.mutation.RedirectTo(); !ok {
  277. v := pendingauthsession.DefaultRedirectTo
  278. _c.mutation.SetRedirectTo(v)
  279. }
  280. if _, ok := _c.mutation.ResolvedEmail(); !ok {
  281. v := pendingauthsession.DefaultResolvedEmail
  282. _c.mutation.SetResolvedEmail(v)
  283. }
  284. if _, ok := _c.mutation.RegistrationPasswordHash(); !ok {
  285. v := pendingauthsession.DefaultRegistrationPasswordHash
  286. _c.mutation.SetRegistrationPasswordHash(v)
  287. }
  288. if _, ok := _c.mutation.UpstreamIdentityClaims(); !ok {
  289. v := pendingauthsession.DefaultUpstreamIdentityClaims()
  290. _c.mutation.SetUpstreamIdentityClaims(v)
  291. }
  292. if _, ok := _c.mutation.LocalFlowState(); !ok {
  293. v := pendingauthsession.DefaultLocalFlowState()
  294. _c.mutation.SetLocalFlowState(v)
  295. }
  296. if _, ok := _c.mutation.BrowserSessionKey(); !ok {
  297. v := pendingauthsession.DefaultBrowserSessionKey
  298. _c.mutation.SetBrowserSessionKey(v)
  299. }
  300. if _, ok := _c.mutation.CompletionCodeHash(); !ok {
  301. v := pendingauthsession.DefaultCompletionCodeHash
  302. _c.mutation.SetCompletionCodeHash(v)
  303. }
  304. }
  305. // check runs all checks and user-defined validators on the builder.
  306. func (_c *PendingAuthSessionCreate) check() error {
  307. if _, ok := _c.mutation.CreatedAt(); !ok {
  308. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PendingAuthSession.created_at"`)}
  309. }
  310. if _, ok := _c.mutation.UpdatedAt(); !ok {
  311. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PendingAuthSession.updated_at"`)}
  312. }
  313. if _, ok := _c.mutation.SessionToken(); !ok {
  314. return &ValidationError{Name: "session_token", err: errors.New(`ent: missing required field "PendingAuthSession.session_token"`)}
  315. }
  316. if v, ok := _c.mutation.SessionToken(); ok {
  317. if err := pendingauthsession.SessionTokenValidator(v); err != nil {
  318. return &ValidationError{Name: "session_token", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.session_token": %w`, err)}
  319. }
  320. }
  321. if _, ok := _c.mutation.Intent(); !ok {
  322. return &ValidationError{Name: "intent", err: errors.New(`ent: missing required field "PendingAuthSession.intent"`)}
  323. }
  324. if v, ok := _c.mutation.Intent(); ok {
  325. if err := pendingauthsession.IntentValidator(v); err != nil {
  326. return &ValidationError{Name: "intent", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.intent": %w`, err)}
  327. }
  328. }
  329. if _, ok := _c.mutation.ProviderType(); !ok {
  330. return &ValidationError{Name: "provider_type", err: errors.New(`ent: missing required field "PendingAuthSession.provider_type"`)}
  331. }
  332. if v, ok := _c.mutation.ProviderType(); ok {
  333. if err := pendingauthsession.ProviderTypeValidator(v); err != nil {
  334. return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_type": %w`, err)}
  335. }
  336. }
  337. if _, ok := _c.mutation.ProviderKey(); !ok {
  338. return &ValidationError{Name: "provider_key", err: errors.New(`ent: missing required field "PendingAuthSession.provider_key"`)}
  339. }
  340. if v, ok := _c.mutation.ProviderKey(); ok {
  341. if err := pendingauthsession.ProviderKeyValidator(v); err != nil {
  342. return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_key": %w`, err)}
  343. }
  344. }
  345. if _, ok := _c.mutation.ProviderSubject(); !ok {
  346. return &ValidationError{Name: "provider_subject", err: errors.New(`ent: missing required field "PendingAuthSession.provider_subject"`)}
  347. }
  348. if v, ok := _c.mutation.ProviderSubject(); ok {
  349. if err := pendingauthsession.ProviderSubjectValidator(v); err != nil {
  350. return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_subject": %w`, err)}
  351. }
  352. }
  353. if _, ok := _c.mutation.RedirectTo(); !ok {
  354. return &ValidationError{Name: "redirect_to", err: errors.New(`ent: missing required field "PendingAuthSession.redirect_to"`)}
  355. }
  356. if _, ok := _c.mutation.ResolvedEmail(); !ok {
  357. return &ValidationError{Name: "resolved_email", err: errors.New(`ent: missing required field "PendingAuthSession.resolved_email"`)}
  358. }
  359. if _, ok := _c.mutation.RegistrationPasswordHash(); !ok {
  360. return &ValidationError{Name: "registration_password_hash", err: errors.New(`ent: missing required field "PendingAuthSession.registration_password_hash"`)}
  361. }
  362. if _, ok := _c.mutation.UpstreamIdentityClaims(); !ok {
  363. return &ValidationError{Name: "upstream_identity_claims", err: errors.New(`ent: missing required field "PendingAuthSession.upstream_identity_claims"`)}
  364. }
  365. if _, ok := _c.mutation.LocalFlowState(); !ok {
  366. return &ValidationError{Name: "local_flow_state", err: errors.New(`ent: missing required field "PendingAuthSession.local_flow_state"`)}
  367. }
  368. if _, ok := _c.mutation.BrowserSessionKey(); !ok {
  369. return &ValidationError{Name: "browser_session_key", err: errors.New(`ent: missing required field "PendingAuthSession.browser_session_key"`)}
  370. }
  371. if _, ok := _c.mutation.CompletionCodeHash(); !ok {
  372. return &ValidationError{Name: "completion_code_hash", err: errors.New(`ent: missing required field "PendingAuthSession.completion_code_hash"`)}
  373. }
  374. if _, ok := _c.mutation.ExpiresAt(); !ok {
  375. return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "PendingAuthSession.expires_at"`)}
  376. }
  377. return nil
  378. }
  379. func (_c *PendingAuthSessionCreate) sqlSave(ctx context.Context) (*PendingAuthSession, error) {
  380. if err := _c.check(); err != nil {
  381. return nil, err
  382. }
  383. _node, _spec := _c.createSpec()
  384. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  385. if sqlgraph.IsConstraintError(err) {
  386. err = &ConstraintError{msg: err.Error(), wrap: err}
  387. }
  388. return nil, err
  389. }
  390. id := _spec.ID.Value.(int64)
  391. _node.ID = int64(id)
  392. _c.mutation.id = &_node.ID
  393. _c.mutation.done = true
  394. return _node, nil
  395. }
  396. func (_c *PendingAuthSessionCreate) createSpec() (*PendingAuthSession, *sqlgraph.CreateSpec) {
  397. var (
  398. _node = &PendingAuthSession{config: _c.config}
  399. _spec = sqlgraph.NewCreateSpec(pendingauthsession.Table, sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64))
  400. )
  401. _spec.OnConflict = _c.conflict
  402. if value, ok := _c.mutation.CreatedAt(); ok {
  403. _spec.SetField(pendingauthsession.FieldCreatedAt, field.TypeTime, value)
  404. _node.CreatedAt = value
  405. }
  406. if value, ok := _c.mutation.UpdatedAt(); ok {
  407. _spec.SetField(pendingauthsession.FieldUpdatedAt, field.TypeTime, value)
  408. _node.UpdatedAt = value
  409. }
  410. if value, ok := _c.mutation.SessionToken(); ok {
  411. _spec.SetField(pendingauthsession.FieldSessionToken, field.TypeString, value)
  412. _node.SessionToken = value
  413. }
  414. if value, ok := _c.mutation.Intent(); ok {
  415. _spec.SetField(pendingauthsession.FieldIntent, field.TypeString, value)
  416. _node.Intent = value
  417. }
  418. if value, ok := _c.mutation.ProviderType(); ok {
  419. _spec.SetField(pendingauthsession.FieldProviderType, field.TypeString, value)
  420. _node.ProviderType = value
  421. }
  422. if value, ok := _c.mutation.ProviderKey(); ok {
  423. _spec.SetField(pendingauthsession.FieldProviderKey, field.TypeString, value)
  424. _node.ProviderKey = value
  425. }
  426. if value, ok := _c.mutation.ProviderSubject(); ok {
  427. _spec.SetField(pendingauthsession.FieldProviderSubject, field.TypeString, value)
  428. _node.ProviderSubject = value
  429. }
  430. if value, ok := _c.mutation.RedirectTo(); ok {
  431. _spec.SetField(pendingauthsession.FieldRedirectTo, field.TypeString, value)
  432. _node.RedirectTo = value
  433. }
  434. if value, ok := _c.mutation.ResolvedEmail(); ok {
  435. _spec.SetField(pendingauthsession.FieldResolvedEmail, field.TypeString, value)
  436. _node.ResolvedEmail = value
  437. }
  438. if value, ok := _c.mutation.RegistrationPasswordHash(); ok {
  439. _spec.SetField(pendingauthsession.FieldRegistrationPasswordHash, field.TypeString, value)
  440. _node.RegistrationPasswordHash = value
  441. }
  442. if value, ok := _c.mutation.UpstreamIdentityClaims(); ok {
  443. _spec.SetField(pendingauthsession.FieldUpstreamIdentityClaims, field.TypeJSON, value)
  444. _node.UpstreamIdentityClaims = value
  445. }
  446. if value, ok := _c.mutation.LocalFlowState(); ok {
  447. _spec.SetField(pendingauthsession.FieldLocalFlowState, field.TypeJSON, value)
  448. _node.LocalFlowState = value
  449. }
  450. if value, ok := _c.mutation.BrowserSessionKey(); ok {
  451. _spec.SetField(pendingauthsession.FieldBrowserSessionKey, field.TypeString, value)
  452. _node.BrowserSessionKey = value
  453. }
  454. if value, ok := _c.mutation.CompletionCodeHash(); ok {
  455. _spec.SetField(pendingauthsession.FieldCompletionCodeHash, field.TypeString, value)
  456. _node.CompletionCodeHash = value
  457. }
  458. if value, ok := _c.mutation.CompletionCodeExpiresAt(); ok {
  459. _spec.SetField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime, value)
  460. _node.CompletionCodeExpiresAt = &value
  461. }
  462. if value, ok := _c.mutation.EmailVerifiedAt(); ok {
  463. _spec.SetField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime, value)
  464. _node.EmailVerifiedAt = &value
  465. }
  466. if value, ok := _c.mutation.PasswordVerifiedAt(); ok {
  467. _spec.SetField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime, value)
  468. _node.PasswordVerifiedAt = &value
  469. }
  470. if value, ok := _c.mutation.TotpVerifiedAt(); ok {
  471. _spec.SetField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime, value)
  472. _node.TotpVerifiedAt = &value
  473. }
  474. if value, ok := _c.mutation.ExpiresAt(); ok {
  475. _spec.SetField(pendingauthsession.FieldExpiresAt, field.TypeTime, value)
  476. _node.ExpiresAt = value
  477. }
  478. if value, ok := _c.mutation.ConsumedAt(); ok {
  479. _spec.SetField(pendingauthsession.FieldConsumedAt, field.TypeTime, value)
  480. _node.ConsumedAt = &value
  481. }
  482. if nodes := _c.mutation.TargetUserIDs(); len(nodes) > 0 {
  483. edge := &sqlgraph.EdgeSpec{
  484. Rel: sqlgraph.M2O,
  485. Inverse: true,
  486. Table: pendingauthsession.TargetUserTable,
  487. Columns: []string{pendingauthsession.TargetUserColumn},
  488. Bidi: false,
  489. Target: &sqlgraph.EdgeTarget{
  490. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  491. },
  492. }
  493. for _, k := range nodes {
  494. edge.Target.Nodes = append(edge.Target.Nodes, k)
  495. }
  496. _node.TargetUserID = &nodes[0]
  497. _spec.Edges = append(_spec.Edges, edge)
  498. }
  499. if nodes := _c.mutation.AdoptionDecisionIDs(); len(nodes) > 0 {
  500. edge := &sqlgraph.EdgeSpec{
  501. Rel: sqlgraph.O2O,
  502. Inverse: false,
  503. Table: pendingauthsession.AdoptionDecisionTable,
  504. Columns: []string{pendingauthsession.AdoptionDecisionColumn},
  505. Bidi: false,
  506. Target: &sqlgraph.EdgeTarget{
  507. IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
  508. },
  509. }
  510. for _, k := range nodes {
  511. edge.Target.Nodes = append(edge.Target.Nodes, k)
  512. }
  513. _spec.Edges = append(_spec.Edges, edge)
  514. }
  515. return _node, _spec
  516. }
  517. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  518. // of the `INSERT` statement. For example:
  519. //
  520. // client.PendingAuthSession.Create().
  521. // SetCreatedAt(v).
  522. // OnConflict(
  523. // // Update the row with the new values
  524. // // the was proposed for insertion.
  525. // sql.ResolveWithNewValues(),
  526. // ).
  527. // // Override some of the fields with custom
  528. // // update values.
  529. // Update(func(u *ent.PendingAuthSessionUpsert) {
  530. // SetCreatedAt(v+v).
  531. // }).
  532. // Exec(ctx)
  533. func (_c *PendingAuthSessionCreate) OnConflict(opts ...sql.ConflictOption) *PendingAuthSessionUpsertOne {
  534. _c.conflict = opts
  535. return &PendingAuthSessionUpsertOne{
  536. create: _c,
  537. }
  538. }
  539. // OnConflictColumns calls `OnConflict` and configures the columns
  540. // as conflict target. Using this option is equivalent to using:
  541. //
  542. // client.PendingAuthSession.Create().
  543. // OnConflict(sql.ConflictColumns(columns...)).
  544. // Exec(ctx)
  545. func (_c *PendingAuthSessionCreate) OnConflictColumns(columns ...string) *PendingAuthSessionUpsertOne {
  546. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  547. return &PendingAuthSessionUpsertOne{
  548. create: _c,
  549. }
  550. }
  551. type (
  552. // PendingAuthSessionUpsertOne is the builder for "upsert"-ing
  553. // one PendingAuthSession node.
  554. PendingAuthSessionUpsertOne struct {
  555. create *PendingAuthSessionCreate
  556. }
  557. // PendingAuthSessionUpsert is the "OnConflict" setter.
  558. PendingAuthSessionUpsert struct {
  559. *sql.UpdateSet
  560. }
  561. )
  562. // SetUpdatedAt sets the "updated_at" field.
  563. func (u *PendingAuthSessionUpsert) SetUpdatedAt(v time.Time) *PendingAuthSessionUpsert {
  564. u.Set(pendingauthsession.FieldUpdatedAt, v)
  565. return u
  566. }
  567. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  568. func (u *PendingAuthSessionUpsert) UpdateUpdatedAt() *PendingAuthSessionUpsert {
  569. u.SetExcluded(pendingauthsession.FieldUpdatedAt)
  570. return u
  571. }
  572. // SetSessionToken sets the "session_token" field.
  573. func (u *PendingAuthSessionUpsert) SetSessionToken(v string) *PendingAuthSessionUpsert {
  574. u.Set(pendingauthsession.FieldSessionToken, v)
  575. return u
  576. }
  577. // UpdateSessionToken sets the "session_token" field to the value that was provided on create.
  578. func (u *PendingAuthSessionUpsert) UpdateSessionToken() *PendingAuthSessionUpsert {
  579. u.SetExcluded(pendingauthsession.FieldSessionToken)
  580. return u
  581. }
  582. // SetIntent sets the "intent" field.
  583. func (u *PendingAuthSessionUpsert) SetIntent(v string) *PendingAuthSessionUpsert {
  584. u.Set(pendingauthsession.FieldIntent, v)
  585. return u
  586. }
  587. // UpdateIntent sets the "intent" field to the value that was provided on create.
  588. func (u *PendingAuthSessionUpsert) UpdateIntent() *PendingAuthSessionUpsert {
  589. u.SetExcluded(pendingauthsession.FieldIntent)
  590. return u
  591. }
  592. // SetProviderType sets the "provider_type" field.
  593. func (u *PendingAuthSessionUpsert) SetProviderType(v string) *PendingAuthSessionUpsert {
  594. u.Set(pendingauthsession.FieldProviderType, v)
  595. return u
  596. }
  597. // UpdateProviderType sets the "provider_type" field to the value that was provided on create.
  598. func (u *PendingAuthSessionUpsert) UpdateProviderType() *PendingAuthSessionUpsert {
  599. u.SetExcluded(pendingauthsession.FieldProviderType)
  600. return u
  601. }
  602. // SetProviderKey sets the "provider_key" field.
  603. func (u *PendingAuthSessionUpsert) SetProviderKey(v string) *PendingAuthSessionUpsert {
  604. u.Set(pendingauthsession.FieldProviderKey, v)
  605. return u
  606. }
  607. // UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
  608. func (u *PendingAuthSessionUpsert) UpdateProviderKey() *PendingAuthSessionUpsert {
  609. u.SetExcluded(pendingauthsession.FieldProviderKey)
  610. return u
  611. }
  612. // SetProviderSubject sets the "provider_subject" field.
  613. func (u *PendingAuthSessionUpsert) SetProviderSubject(v string) *PendingAuthSessionUpsert {
  614. u.Set(pendingauthsession.FieldProviderSubject, v)
  615. return u
  616. }
  617. // UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
  618. func (u *PendingAuthSessionUpsert) UpdateProviderSubject() *PendingAuthSessionUpsert {
  619. u.SetExcluded(pendingauthsession.FieldProviderSubject)
  620. return u
  621. }
  622. // SetTargetUserID sets the "target_user_id" field.
  623. func (u *PendingAuthSessionUpsert) SetTargetUserID(v int64) *PendingAuthSessionUpsert {
  624. u.Set(pendingauthsession.FieldTargetUserID, v)
  625. return u
  626. }
  627. // UpdateTargetUserID sets the "target_user_id" field to the value that was provided on create.
  628. func (u *PendingAuthSessionUpsert) UpdateTargetUserID() *PendingAuthSessionUpsert {
  629. u.SetExcluded(pendingauthsession.FieldTargetUserID)
  630. return u
  631. }
  632. // ClearTargetUserID clears the value of the "target_user_id" field.
  633. func (u *PendingAuthSessionUpsert) ClearTargetUserID() *PendingAuthSessionUpsert {
  634. u.SetNull(pendingauthsession.FieldTargetUserID)
  635. return u
  636. }
  637. // SetRedirectTo sets the "redirect_to" field.
  638. func (u *PendingAuthSessionUpsert) SetRedirectTo(v string) *PendingAuthSessionUpsert {
  639. u.Set(pendingauthsession.FieldRedirectTo, v)
  640. return u
  641. }
  642. // UpdateRedirectTo sets the "redirect_to" field to the value that was provided on create.
  643. func (u *PendingAuthSessionUpsert) UpdateRedirectTo() *PendingAuthSessionUpsert {
  644. u.SetExcluded(pendingauthsession.FieldRedirectTo)
  645. return u
  646. }
  647. // SetResolvedEmail sets the "resolved_email" field.
  648. func (u *PendingAuthSessionUpsert) SetResolvedEmail(v string) *PendingAuthSessionUpsert {
  649. u.Set(pendingauthsession.FieldResolvedEmail, v)
  650. return u
  651. }
  652. // UpdateResolvedEmail sets the "resolved_email" field to the value that was provided on create.
  653. func (u *PendingAuthSessionUpsert) UpdateResolvedEmail() *PendingAuthSessionUpsert {
  654. u.SetExcluded(pendingauthsession.FieldResolvedEmail)
  655. return u
  656. }
  657. // SetRegistrationPasswordHash sets the "registration_password_hash" field.
  658. func (u *PendingAuthSessionUpsert) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpsert {
  659. u.Set(pendingauthsession.FieldRegistrationPasswordHash, v)
  660. return u
  661. }
  662. // UpdateRegistrationPasswordHash sets the "registration_password_hash" field to the value that was provided on create.
  663. func (u *PendingAuthSessionUpsert) UpdateRegistrationPasswordHash() *PendingAuthSessionUpsert {
  664. u.SetExcluded(pendingauthsession.FieldRegistrationPasswordHash)
  665. return u
  666. }
  667. // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
  668. func (u *PendingAuthSessionUpsert) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpsert {
  669. u.Set(pendingauthsession.FieldUpstreamIdentityClaims, v)
  670. return u
  671. }
  672. // UpdateUpstreamIdentityClaims sets the "upstream_identity_claims" field to the value that was provided on create.
  673. func (u *PendingAuthSessionUpsert) UpdateUpstreamIdentityClaims() *PendingAuthSessionUpsert {
  674. u.SetExcluded(pendingauthsession.FieldUpstreamIdentityClaims)
  675. return u
  676. }
  677. // SetLocalFlowState sets the "local_flow_state" field.
  678. func (u *PendingAuthSessionUpsert) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpsert {
  679. u.Set(pendingauthsession.FieldLocalFlowState, v)
  680. return u
  681. }
  682. // UpdateLocalFlowState sets the "local_flow_state" field to the value that was provided on create.
  683. func (u *PendingAuthSessionUpsert) UpdateLocalFlowState() *PendingAuthSessionUpsert {
  684. u.SetExcluded(pendingauthsession.FieldLocalFlowState)
  685. return u
  686. }
  687. // SetBrowserSessionKey sets the "browser_session_key" field.
  688. func (u *PendingAuthSessionUpsert) SetBrowserSessionKey(v string) *PendingAuthSessionUpsert {
  689. u.Set(pendingauthsession.FieldBrowserSessionKey, v)
  690. return u
  691. }
  692. // UpdateBrowserSessionKey sets the "browser_session_key" field to the value that was provided on create.
  693. func (u *PendingAuthSessionUpsert) UpdateBrowserSessionKey() *PendingAuthSessionUpsert {
  694. u.SetExcluded(pendingauthsession.FieldBrowserSessionKey)
  695. return u
  696. }
  697. // SetCompletionCodeHash sets the "completion_code_hash" field.
  698. func (u *PendingAuthSessionUpsert) SetCompletionCodeHash(v string) *PendingAuthSessionUpsert {
  699. u.Set(pendingauthsession.FieldCompletionCodeHash, v)
  700. return u
  701. }
  702. // UpdateCompletionCodeHash sets the "completion_code_hash" field to the value that was provided on create.
  703. func (u *PendingAuthSessionUpsert) UpdateCompletionCodeHash() *PendingAuthSessionUpsert {
  704. u.SetExcluded(pendingauthsession.FieldCompletionCodeHash)
  705. return u
  706. }
  707. // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
  708. func (u *PendingAuthSessionUpsert) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpsert {
  709. u.Set(pendingauthsession.FieldCompletionCodeExpiresAt, v)
  710. return u
  711. }
  712. // UpdateCompletionCodeExpiresAt sets the "completion_code_expires_at" field to the value that was provided on create.
  713. func (u *PendingAuthSessionUpsert) UpdateCompletionCodeExpiresAt() *PendingAuthSessionUpsert {
  714. u.SetExcluded(pendingauthsession.FieldCompletionCodeExpiresAt)
  715. return u
  716. }
  717. // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
  718. func (u *PendingAuthSessionUpsert) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpsert {
  719. u.SetNull(pendingauthsession.FieldCompletionCodeExpiresAt)
  720. return u
  721. }
  722. // SetEmailVerifiedAt sets the "email_verified_at" field.
  723. func (u *PendingAuthSessionUpsert) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpsert {
  724. u.Set(pendingauthsession.FieldEmailVerifiedAt, v)
  725. return u
  726. }
  727. // UpdateEmailVerifiedAt sets the "email_verified_at" field to the value that was provided on create.
  728. func (u *PendingAuthSessionUpsert) UpdateEmailVerifiedAt() *PendingAuthSessionUpsert {
  729. u.SetExcluded(pendingauthsession.FieldEmailVerifiedAt)
  730. return u
  731. }
  732. // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
  733. func (u *PendingAuthSessionUpsert) ClearEmailVerifiedAt() *PendingAuthSessionUpsert {
  734. u.SetNull(pendingauthsession.FieldEmailVerifiedAt)
  735. return u
  736. }
  737. // SetPasswordVerifiedAt sets the "password_verified_at" field.
  738. func (u *PendingAuthSessionUpsert) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpsert {
  739. u.Set(pendingauthsession.FieldPasswordVerifiedAt, v)
  740. return u
  741. }
  742. // UpdatePasswordVerifiedAt sets the "password_verified_at" field to the value that was provided on create.
  743. func (u *PendingAuthSessionUpsert) UpdatePasswordVerifiedAt() *PendingAuthSessionUpsert {
  744. u.SetExcluded(pendingauthsession.FieldPasswordVerifiedAt)
  745. return u
  746. }
  747. // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
  748. func (u *PendingAuthSessionUpsert) ClearPasswordVerifiedAt() *PendingAuthSessionUpsert {
  749. u.SetNull(pendingauthsession.FieldPasswordVerifiedAt)
  750. return u
  751. }
  752. // SetTotpVerifiedAt sets the "totp_verified_at" field.
  753. func (u *PendingAuthSessionUpsert) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpsert {
  754. u.Set(pendingauthsession.FieldTotpVerifiedAt, v)
  755. return u
  756. }
  757. // UpdateTotpVerifiedAt sets the "totp_verified_at" field to the value that was provided on create.
  758. func (u *PendingAuthSessionUpsert) UpdateTotpVerifiedAt() *PendingAuthSessionUpsert {
  759. u.SetExcluded(pendingauthsession.FieldTotpVerifiedAt)
  760. return u
  761. }
  762. // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
  763. func (u *PendingAuthSessionUpsert) ClearTotpVerifiedAt() *PendingAuthSessionUpsert {
  764. u.SetNull(pendingauthsession.FieldTotpVerifiedAt)
  765. return u
  766. }
  767. // SetExpiresAt sets the "expires_at" field.
  768. func (u *PendingAuthSessionUpsert) SetExpiresAt(v time.Time) *PendingAuthSessionUpsert {
  769. u.Set(pendingauthsession.FieldExpiresAt, v)
  770. return u
  771. }
  772. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  773. func (u *PendingAuthSessionUpsert) UpdateExpiresAt() *PendingAuthSessionUpsert {
  774. u.SetExcluded(pendingauthsession.FieldExpiresAt)
  775. return u
  776. }
  777. // SetConsumedAt sets the "consumed_at" field.
  778. func (u *PendingAuthSessionUpsert) SetConsumedAt(v time.Time) *PendingAuthSessionUpsert {
  779. u.Set(pendingauthsession.FieldConsumedAt, v)
  780. return u
  781. }
  782. // UpdateConsumedAt sets the "consumed_at" field to the value that was provided on create.
  783. func (u *PendingAuthSessionUpsert) UpdateConsumedAt() *PendingAuthSessionUpsert {
  784. u.SetExcluded(pendingauthsession.FieldConsumedAt)
  785. return u
  786. }
  787. // ClearConsumedAt clears the value of the "consumed_at" field.
  788. func (u *PendingAuthSessionUpsert) ClearConsumedAt() *PendingAuthSessionUpsert {
  789. u.SetNull(pendingauthsession.FieldConsumedAt)
  790. return u
  791. }
  792. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  793. // Using this option is equivalent to using:
  794. //
  795. // client.PendingAuthSession.Create().
  796. // OnConflict(
  797. // sql.ResolveWithNewValues(),
  798. // ).
  799. // Exec(ctx)
  800. func (u *PendingAuthSessionUpsertOne) UpdateNewValues() *PendingAuthSessionUpsertOne {
  801. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  802. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  803. if _, exists := u.create.mutation.CreatedAt(); exists {
  804. s.SetIgnore(pendingauthsession.FieldCreatedAt)
  805. }
  806. }))
  807. return u
  808. }
  809. // Ignore sets each column to itself in case of conflict.
  810. // Using this option is equivalent to using:
  811. //
  812. // client.PendingAuthSession.Create().
  813. // OnConflict(sql.ResolveWithIgnore()).
  814. // Exec(ctx)
  815. func (u *PendingAuthSessionUpsertOne) Ignore() *PendingAuthSessionUpsertOne {
  816. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  817. return u
  818. }
  819. // DoNothing configures the conflict_action to `DO NOTHING`.
  820. // Supported only by SQLite and PostgreSQL.
  821. func (u *PendingAuthSessionUpsertOne) DoNothing() *PendingAuthSessionUpsertOne {
  822. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  823. return u
  824. }
  825. // Update allows overriding fields `UPDATE` values. See the PendingAuthSessionCreate.OnConflict
  826. // documentation for more info.
  827. func (u *PendingAuthSessionUpsertOne) Update(set func(*PendingAuthSessionUpsert)) *PendingAuthSessionUpsertOne {
  828. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  829. set(&PendingAuthSessionUpsert{UpdateSet: update})
  830. }))
  831. return u
  832. }
  833. // SetUpdatedAt sets the "updated_at" field.
  834. func (u *PendingAuthSessionUpsertOne) SetUpdatedAt(v time.Time) *PendingAuthSessionUpsertOne {
  835. return u.Update(func(s *PendingAuthSessionUpsert) {
  836. s.SetUpdatedAt(v)
  837. })
  838. }
  839. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  840. func (u *PendingAuthSessionUpsertOne) UpdateUpdatedAt() *PendingAuthSessionUpsertOne {
  841. return u.Update(func(s *PendingAuthSessionUpsert) {
  842. s.UpdateUpdatedAt()
  843. })
  844. }
  845. // SetSessionToken sets the "session_token" field.
  846. func (u *PendingAuthSessionUpsertOne) SetSessionToken(v string) *PendingAuthSessionUpsertOne {
  847. return u.Update(func(s *PendingAuthSessionUpsert) {
  848. s.SetSessionToken(v)
  849. })
  850. }
  851. // UpdateSessionToken sets the "session_token" field to the value that was provided on create.
  852. func (u *PendingAuthSessionUpsertOne) UpdateSessionToken() *PendingAuthSessionUpsertOne {
  853. return u.Update(func(s *PendingAuthSessionUpsert) {
  854. s.UpdateSessionToken()
  855. })
  856. }
  857. // SetIntent sets the "intent" field.
  858. func (u *PendingAuthSessionUpsertOne) SetIntent(v string) *PendingAuthSessionUpsertOne {
  859. return u.Update(func(s *PendingAuthSessionUpsert) {
  860. s.SetIntent(v)
  861. })
  862. }
  863. // UpdateIntent sets the "intent" field to the value that was provided on create.
  864. func (u *PendingAuthSessionUpsertOne) UpdateIntent() *PendingAuthSessionUpsertOne {
  865. return u.Update(func(s *PendingAuthSessionUpsert) {
  866. s.UpdateIntent()
  867. })
  868. }
  869. // SetProviderType sets the "provider_type" field.
  870. func (u *PendingAuthSessionUpsertOne) SetProviderType(v string) *PendingAuthSessionUpsertOne {
  871. return u.Update(func(s *PendingAuthSessionUpsert) {
  872. s.SetProviderType(v)
  873. })
  874. }
  875. // UpdateProviderType sets the "provider_type" field to the value that was provided on create.
  876. func (u *PendingAuthSessionUpsertOne) UpdateProviderType() *PendingAuthSessionUpsertOne {
  877. return u.Update(func(s *PendingAuthSessionUpsert) {
  878. s.UpdateProviderType()
  879. })
  880. }
  881. // SetProviderKey sets the "provider_key" field.
  882. func (u *PendingAuthSessionUpsertOne) SetProviderKey(v string) *PendingAuthSessionUpsertOne {
  883. return u.Update(func(s *PendingAuthSessionUpsert) {
  884. s.SetProviderKey(v)
  885. })
  886. }
  887. // UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
  888. func (u *PendingAuthSessionUpsertOne) UpdateProviderKey() *PendingAuthSessionUpsertOne {
  889. return u.Update(func(s *PendingAuthSessionUpsert) {
  890. s.UpdateProviderKey()
  891. })
  892. }
  893. // SetProviderSubject sets the "provider_subject" field.
  894. func (u *PendingAuthSessionUpsertOne) SetProviderSubject(v string) *PendingAuthSessionUpsertOne {
  895. return u.Update(func(s *PendingAuthSessionUpsert) {
  896. s.SetProviderSubject(v)
  897. })
  898. }
  899. // UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
  900. func (u *PendingAuthSessionUpsertOne) UpdateProviderSubject() *PendingAuthSessionUpsertOne {
  901. return u.Update(func(s *PendingAuthSessionUpsert) {
  902. s.UpdateProviderSubject()
  903. })
  904. }
  905. // SetTargetUserID sets the "target_user_id" field.
  906. func (u *PendingAuthSessionUpsertOne) SetTargetUserID(v int64) *PendingAuthSessionUpsertOne {
  907. return u.Update(func(s *PendingAuthSessionUpsert) {
  908. s.SetTargetUserID(v)
  909. })
  910. }
  911. // UpdateTargetUserID sets the "target_user_id" field to the value that was provided on create.
  912. func (u *PendingAuthSessionUpsertOne) UpdateTargetUserID() *PendingAuthSessionUpsertOne {
  913. return u.Update(func(s *PendingAuthSessionUpsert) {
  914. s.UpdateTargetUserID()
  915. })
  916. }
  917. // ClearTargetUserID clears the value of the "target_user_id" field.
  918. func (u *PendingAuthSessionUpsertOne) ClearTargetUserID() *PendingAuthSessionUpsertOne {
  919. return u.Update(func(s *PendingAuthSessionUpsert) {
  920. s.ClearTargetUserID()
  921. })
  922. }
  923. // SetRedirectTo sets the "redirect_to" field.
  924. func (u *PendingAuthSessionUpsertOne) SetRedirectTo(v string) *PendingAuthSessionUpsertOne {
  925. return u.Update(func(s *PendingAuthSessionUpsert) {
  926. s.SetRedirectTo(v)
  927. })
  928. }
  929. // UpdateRedirectTo sets the "redirect_to" field to the value that was provided on create.
  930. func (u *PendingAuthSessionUpsertOne) UpdateRedirectTo() *PendingAuthSessionUpsertOne {
  931. return u.Update(func(s *PendingAuthSessionUpsert) {
  932. s.UpdateRedirectTo()
  933. })
  934. }
  935. // SetResolvedEmail sets the "resolved_email" field.
  936. func (u *PendingAuthSessionUpsertOne) SetResolvedEmail(v string) *PendingAuthSessionUpsertOne {
  937. return u.Update(func(s *PendingAuthSessionUpsert) {
  938. s.SetResolvedEmail(v)
  939. })
  940. }
  941. // UpdateResolvedEmail sets the "resolved_email" field to the value that was provided on create.
  942. func (u *PendingAuthSessionUpsertOne) UpdateResolvedEmail() *PendingAuthSessionUpsertOne {
  943. return u.Update(func(s *PendingAuthSessionUpsert) {
  944. s.UpdateResolvedEmail()
  945. })
  946. }
  947. // SetRegistrationPasswordHash sets the "registration_password_hash" field.
  948. func (u *PendingAuthSessionUpsertOne) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpsertOne {
  949. return u.Update(func(s *PendingAuthSessionUpsert) {
  950. s.SetRegistrationPasswordHash(v)
  951. })
  952. }
  953. // UpdateRegistrationPasswordHash sets the "registration_password_hash" field to the value that was provided on create.
  954. func (u *PendingAuthSessionUpsertOne) UpdateRegistrationPasswordHash() *PendingAuthSessionUpsertOne {
  955. return u.Update(func(s *PendingAuthSessionUpsert) {
  956. s.UpdateRegistrationPasswordHash()
  957. })
  958. }
  959. // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
  960. func (u *PendingAuthSessionUpsertOne) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpsertOne {
  961. return u.Update(func(s *PendingAuthSessionUpsert) {
  962. s.SetUpstreamIdentityClaims(v)
  963. })
  964. }
  965. // UpdateUpstreamIdentityClaims sets the "upstream_identity_claims" field to the value that was provided on create.
  966. func (u *PendingAuthSessionUpsertOne) UpdateUpstreamIdentityClaims() *PendingAuthSessionUpsertOne {
  967. return u.Update(func(s *PendingAuthSessionUpsert) {
  968. s.UpdateUpstreamIdentityClaims()
  969. })
  970. }
  971. // SetLocalFlowState sets the "local_flow_state" field.
  972. func (u *PendingAuthSessionUpsertOne) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpsertOne {
  973. return u.Update(func(s *PendingAuthSessionUpsert) {
  974. s.SetLocalFlowState(v)
  975. })
  976. }
  977. // UpdateLocalFlowState sets the "local_flow_state" field to the value that was provided on create.
  978. func (u *PendingAuthSessionUpsertOne) UpdateLocalFlowState() *PendingAuthSessionUpsertOne {
  979. return u.Update(func(s *PendingAuthSessionUpsert) {
  980. s.UpdateLocalFlowState()
  981. })
  982. }
  983. // SetBrowserSessionKey sets the "browser_session_key" field.
  984. func (u *PendingAuthSessionUpsertOne) SetBrowserSessionKey(v string) *PendingAuthSessionUpsertOne {
  985. return u.Update(func(s *PendingAuthSessionUpsert) {
  986. s.SetBrowserSessionKey(v)
  987. })
  988. }
  989. // UpdateBrowserSessionKey sets the "browser_session_key" field to the value that was provided on create.
  990. func (u *PendingAuthSessionUpsertOne) UpdateBrowserSessionKey() *PendingAuthSessionUpsertOne {
  991. return u.Update(func(s *PendingAuthSessionUpsert) {
  992. s.UpdateBrowserSessionKey()
  993. })
  994. }
  995. // SetCompletionCodeHash sets the "completion_code_hash" field.
  996. func (u *PendingAuthSessionUpsertOne) SetCompletionCodeHash(v string) *PendingAuthSessionUpsertOne {
  997. return u.Update(func(s *PendingAuthSessionUpsert) {
  998. s.SetCompletionCodeHash(v)
  999. })
  1000. }
  1001. // UpdateCompletionCodeHash sets the "completion_code_hash" field to the value that was provided on create.
  1002. func (u *PendingAuthSessionUpsertOne) UpdateCompletionCodeHash() *PendingAuthSessionUpsertOne {
  1003. return u.Update(func(s *PendingAuthSessionUpsert) {
  1004. s.UpdateCompletionCodeHash()
  1005. })
  1006. }
  1007. // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
  1008. func (u *PendingAuthSessionUpsertOne) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpsertOne {
  1009. return u.Update(func(s *PendingAuthSessionUpsert) {
  1010. s.SetCompletionCodeExpiresAt(v)
  1011. })
  1012. }
  1013. // UpdateCompletionCodeExpiresAt sets the "completion_code_expires_at" field to the value that was provided on create.
  1014. func (u *PendingAuthSessionUpsertOne) UpdateCompletionCodeExpiresAt() *PendingAuthSessionUpsertOne {
  1015. return u.Update(func(s *PendingAuthSessionUpsert) {
  1016. s.UpdateCompletionCodeExpiresAt()
  1017. })
  1018. }
  1019. // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
  1020. func (u *PendingAuthSessionUpsertOne) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpsertOne {
  1021. return u.Update(func(s *PendingAuthSessionUpsert) {
  1022. s.ClearCompletionCodeExpiresAt()
  1023. })
  1024. }
  1025. // SetEmailVerifiedAt sets the "email_verified_at" field.
  1026. func (u *PendingAuthSessionUpsertOne) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpsertOne {
  1027. return u.Update(func(s *PendingAuthSessionUpsert) {
  1028. s.SetEmailVerifiedAt(v)
  1029. })
  1030. }
  1031. // UpdateEmailVerifiedAt sets the "email_verified_at" field to the value that was provided on create.
  1032. func (u *PendingAuthSessionUpsertOne) UpdateEmailVerifiedAt() *PendingAuthSessionUpsertOne {
  1033. return u.Update(func(s *PendingAuthSessionUpsert) {
  1034. s.UpdateEmailVerifiedAt()
  1035. })
  1036. }
  1037. // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
  1038. func (u *PendingAuthSessionUpsertOne) ClearEmailVerifiedAt() *PendingAuthSessionUpsertOne {
  1039. return u.Update(func(s *PendingAuthSessionUpsert) {
  1040. s.ClearEmailVerifiedAt()
  1041. })
  1042. }
  1043. // SetPasswordVerifiedAt sets the "password_verified_at" field.
  1044. func (u *PendingAuthSessionUpsertOne) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpsertOne {
  1045. return u.Update(func(s *PendingAuthSessionUpsert) {
  1046. s.SetPasswordVerifiedAt(v)
  1047. })
  1048. }
  1049. // UpdatePasswordVerifiedAt sets the "password_verified_at" field to the value that was provided on create.
  1050. func (u *PendingAuthSessionUpsertOne) UpdatePasswordVerifiedAt() *PendingAuthSessionUpsertOne {
  1051. return u.Update(func(s *PendingAuthSessionUpsert) {
  1052. s.UpdatePasswordVerifiedAt()
  1053. })
  1054. }
  1055. // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
  1056. func (u *PendingAuthSessionUpsertOne) ClearPasswordVerifiedAt() *PendingAuthSessionUpsertOne {
  1057. return u.Update(func(s *PendingAuthSessionUpsert) {
  1058. s.ClearPasswordVerifiedAt()
  1059. })
  1060. }
  1061. // SetTotpVerifiedAt sets the "totp_verified_at" field.
  1062. func (u *PendingAuthSessionUpsertOne) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpsertOne {
  1063. return u.Update(func(s *PendingAuthSessionUpsert) {
  1064. s.SetTotpVerifiedAt(v)
  1065. })
  1066. }
  1067. // UpdateTotpVerifiedAt sets the "totp_verified_at" field to the value that was provided on create.
  1068. func (u *PendingAuthSessionUpsertOne) UpdateTotpVerifiedAt() *PendingAuthSessionUpsertOne {
  1069. return u.Update(func(s *PendingAuthSessionUpsert) {
  1070. s.UpdateTotpVerifiedAt()
  1071. })
  1072. }
  1073. // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
  1074. func (u *PendingAuthSessionUpsertOne) ClearTotpVerifiedAt() *PendingAuthSessionUpsertOne {
  1075. return u.Update(func(s *PendingAuthSessionUpsert) {
  1076. s.ClearTotpVerifiedAt()
  1077. })
  1078. }
  1079. // SetExpiresAt sets the "expires_at" field.
  1080. func (u *PendingAuthSessionUpsertOne) SetExpiresAt(v time.Time) *PendingAuthSessionUpsertOne {
  1081. return u.Update(func(s *PendingAuthSessionUpsert) {
  1082. s.SetExpiresAt(v)
  1083. })
  1084. }
  1085. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  1086. func (u *PendingAuthSessionUpsertOne) UpdateExpiresAt() *PendingAuthSessionUpsertOne {
  1087. return u.Update(func(s *PendingAuthSessionUpsert) {
  1088. s.UpdateExpiresAt()
  1089. })
  1090. }
  1091. // SetConsumedAt sets the "consumed_at" field.
  1092. func (u *PendingAuthSessionUpsertOne) SetConsumedAt(v time.Time) *PendingAuthSessionUpsertOne {
  1093. return u.Update(func(s *PendingAuthSessionUpsert) {
  1094. s.SetConsumedAt(v)
  1095. })
  1096. }
  1097. // UpdateConsumedAt sets the "consumed_at" field to the value that was provided on create.
  1098. func (u *PendingAuthSessionUpsertOne) UpdateConsumedAt() *PendingAuthSessionUpsertOne {
  1099. return u.Update(func(s *PendingAuthSessionUpsert) {
  1100. s.UpdateConsumedAt()
  1101. })
  1102. }
  1103. // ClearConsumedAt clears the value of the "consumed_at" field.
  1104. func (u *PendingAuthSessionUpsertOne) ClearConsumedAt() *PendingAuthSessionUpsertOne {
  1105. return u.Update(func(s *PendingAuthSessionUpsert) {
  1106. s.ClearConsumedAt()
  1107. })
  1108. }
  1109. // Exec executes the query.
  1110. func (u *PendingAuthSessionUpsertOne) Exec(ctx context.Context) error {
  1111. if len(u.create.conflict) == 0 {
  1112. return errors.New("ent: missing options for PendingAuthSessionCreate.OnConflict")
  1113. }
  1114. return u.create.Exec(ctx)
  1115. }
  1116. // ExecX is like Exec, but panics if an error occurs.
  1117. func (u *PendingAuthSessionUpsertOne) ExecX(ctx context.Context) {
  1118. if err := u.create.Exec(ctx); err != nil {
  1119. panic(err)
  1120. }
  1121. }
  1122. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1123. func (u *PendingAuthSessionUpsertOne) ID(ctx context.Context) (id int64, err error) {
  1124. node, err := u.create.Save(ctx)
  1125. if err != nil {
  1126. return id, err
  1127. }
  1128. return node.ID, nil
  1129. }
  1130. // IDX is like ID, but panics if an error occurs.
  1131. func (u *PendingAuthSessionUpsertOne) IDX(ctx context.Context) int64 {
  1132. id, err := u.ID(ctx)
  1133. if err != nil {
  1134. panic(err)
  1135. }
  1136. return id
  1137. }
  1138. // PendingAuthSessionCreateBulk is the builder for creating many PendingAuthSession entities in bulk.
  1139. type PendingAuthSessionCreateBulk struct {
  1140. config
  1141. err error
  1142. builders []*PendingAuthSessionCreate
  1143. conflict []sql.ConflictOption
  1144. }
  1145. // Save creates the PendingAuthSession entities in the database.
  1146. func (_c *PendingAuthSessionCreateBulk) Save(ctx context.Context) ([]*PendingAuthSession, error) {
  1147. if _c.err != nil {
  1148. return nil, _c.err
  1149. }
  1150. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  1151. nodes := make([]*PendingAuthSession, len(_c.builders))
  1152. mutators := make([]Mutator, len(_c.builders))
  1153. for i := range _c.builders {
  1154. func(i int, root context.Context) {
  1155. builder := _c.builders[i]
  1156. builder.defaults()
  1157. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1158. mutation, ok := m.(*PendingAuthSessionMutation)
  1159. if !ok {
  1160. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1161. }
  1162. if err := builder.check(); err != nil {
  1163. return nil, err
  1164. }
  1165. builder.mutation = mutation
  1166. var err error
  1167. nodes[i], specs[i] = builder.createSpec()
  1168. if i < len(mutators)-1 {
  1169. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  1170. } else {
  1171. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1172. spec.OnConflict = _c.conflict
  1173. // Invoke the actual operation on the latest mutation in the chain.
  1174. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  1175. if sqlgraph.IsConstraintError(err) {
  1176. err = &ConstraintError{msg: err.Error(), wrap: err}
  1177. }
  1178. }
  1179. }
  1180. if err != nil {
  1181. return nil, err
  1182. }
  1183. mutation.id = &nodes[i].ID
  1184. if specs[i].ID.Value != nil {
  1185. id := specs[i].ID.Value.(int64)
  1186. nodes[i].ID = int64(id)
  1187. }
  1188. mutation.done = true
  1189. return nodes[i], nil
  1190. })
  1191. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1192. mut = builder.hooks[i](mut)
  1193. }
  1194. mutators[i] = mut
  1195. }(i, ctx)
  1196. }
  1197. if len(mutators) > 0 {
  1198. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  1199. return nil, err
  1200. }
  1201. }
  1202. return nodes, nil
  1203. }
  1204. // SaveX is like Save, but panics if an error occurs.
  1205. func (_c *PendingAuthSessionCreateBulk) SaveX(ctx context.Context) []*PendingAuthSession {
  1206. v, err := _c.Save(ctx)
  1207. if err != nil {
  1208. panic(err)
  1209. }
  1210. return v
  1211. }
  1212. // Exec executes the query.
  1213. func (_c *PendingAuthSessionCreateBulk) Exec(ctx context.Context) error {
  1214. _, err := _c.Save(ctx)
  1215. return err
  1216. }
  1217. // ExecX is like Exec, but panics if an error occurs.
  1218. func (_c *PendingAuthSessionCreateBulk) ExecX(ctx context.Context) {
  1219. if err := _c.Exec(ctx); err != nil {
  1220. panic(err)
  1221. }
  1222. }
  1223. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1224. // of the `INSERT` statement. For example:
  1225. //
  1226. // client.PendingAuthSession.CreateBulk(builders...).
  1227. // OnConflict(
  1228. // // Update the row with the new values
  1229. // // the was proposed for insertion.
  1230. // sql.ResolveWithNewValues(),
  1231. // ).
  1232. // // Override some of the fields with custom
  1233. // // update values.
  1234. // Update(func(u *ent.PendingAuthSessionUpsert) {
  1235. // SetCreatedAt(v+v).
  1236. // }).
  1237. // Exec(ctx)
  1238. func (_c *PendingAuthSessionCreateBulk) OnConflict(opts ...sql.ConflictOption) *PendingAuthSessionUpsertBulk {
  1239. _c.conflict = opts
  1240. return &PendingAuthSessionUpsertBulk{
  1241. create: _c,
  1242. }
  1243. }
  1244. // OnConflictColumns calls `OnConflict` and configures the columns
  1245. // as conflict target. Using this option is equivalent to using:
  1246. //
  1247. // client.PendingAuthSession.Create().
  1248. // OnConflict(sql.ConflictColumns(columns...)).
  1249. // Exec(ctx)
  1250. func (_c *PendingAuthSessionCreateBulk) OnConflictColumns(columns ...string) *PendingAuthSessionUpsertBulk {
  1251. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1252. return &PendingAuthSessionUpsertBulk{
  1253. create: _c,
  1254. }
  1255. }
  1256. // PendingAuthSessionUpsertBulk is the builder for "upsert"-ing
  1257. // a bulk of PendingAuthSession nodes.
  1258. type PendingAuthSessionUpsertBulk struct {
  1259. create *PendingAuthSessionCreateBulk
  1260. }
  1261. // UpdateNewValues updates the mutable fields using the new values that
  1262. // were set on create. Using this option is equivalent to using:
  1263. //
  1264. // client.PendingAuthSession.Create().
  1265. // OnConflict(
  1266. // sql.ResolveWithNewValues(),
  1267. // ).
  1268. // Exec(ctx)
  1269. func (u *PendingAuthSessionUpsertBulk) UpdateNewValues() *PendingAuthSessionUpsertBulk {
  1270. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1271. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1272. for _, b := range u.create.builders {
  1273. if _, exists := b.mutation.CreatedAt(); exists {
  1274. s.SetIgnore(pendingauthsession.FieldCreatedAt)
  1275. }
  1276. }
  1277. }))
  1278. return u
  1279. }
  1280. // Ignore sets each column to itself in case of conflict.
  1281. // Using this option is equivalent to using:
  1282. //
  1283. // client.PendingAuthSession.Create().
  1284. // OnConflict(sql.ResolveWithIgnore()).
  1285. // Exec(ctx)
  1286. func (u *PendingAuthSessionUpsertBulk) Ignore() *PendingAuthSessionUpsertBulk {
  1287. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1288. return u
  1289. }
  1290. // DoNothing configures the conflict_action to `DO NOTHING`.
  1291. // Supported only by SQLite and PostgreSQL.
  1292. func (u *PendingAuthSessionUpsertBulk) DoNothing() *PendingAuthSessionUpsertBulk {
  1293. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1294. return u
  1295. }
  1296. // Update allows overriding fields `UPDATE` values. See the PendingAuthSessionCreateBulk.OnConflict
  1297. // documentation for more info.
  1298. func (u *PendingAuthSessionUpsertBulk) Update(set func(*PendingAuthSessionUpsert)) *PendingAuthSessionUpsertBulk {
  1299. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1300. set(&PendingAuthSessionUpsert{UpdateSet: update})
  1301. }))
  1302. return u
  1303. }
  1304. // SetUpdatedAt sets the "updated_at" field.
  1305. func (u *PendingAuthSessionUpsertBulk) SetUpdatedAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1306. return u.Update(func(s *PendingAuthSessionUpsert) {
  1307. s.SetUpdatedAt(v)
  1308. })
  1309. }
  1310. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1311. func (u *PendingAuthSessionUpsertBulk) UpdateUpdatedAt() *PendingAuthSessionUpsertBulk {
  1312. return u.Update(func(s *PendingAuthSessionUpsert) {
  1313. s.UpdateUpdatedAt()
  1314. })
  1315. }
  1316. // SetSessionToken sets the "session_token" field.
  1317. func (u *PendingAuthSessionUpsertBulk) SetSessionToken(v string) *PendingAuthSessionUpsertBulk {
  1318. return u.Update(func(s *PendingAuthSessionUpsert) {
  1319. s.SetSessionToken(v)
  1320. })
  1321. }
  1322. // UpdateSessionToken sets the "session_token" field to the value that was provided on create.
  1323. func (u *PendingAuthSessionUpsertBulk) UpdateSessionToken() *PendingAuthSessionUpsertBulk {
  1324. return u.Update(func(s *PendingAuthSessionUpsert) {
  1325. s.UpdateSessionToken()
  1326. })
  1327. }
  1328. // SetIntent sets the "intent" field.
  1329. func (u *PendingAuthSessionUpsertBulk) SetIntent(v string) *PendingAuthSessionUpsertBulk {
  1330. return u.Update(func(s *PendingAuthSessionUpsert) {
  1331. s.SetIntent(v)
  1332. })
  1333. }
  1334. // UpdateIntent sets the "intent" field to the value that was provided on create.
  1335. func (u *PendingAuthSessionUpsertBulk) UpdateIntent() *PendingAuthSessionUpsertBulk {
  1336. return u.Update(func(s *PendingAuthSessionUpsert) {
  1337. s.UpdateIntent()
  1338. })
  1339. }
  1340. // SetProviderType sets the "provider_type" field.
  1341. func (u *PendingAuthSessionUpsertBulk) SetProviderType(v string) *PendingAuthSessionUpsertBulk {
  1342. return u.Update(func(s *PendingAuthSessionUpsert) {
  1343. s.SetProviderType(v)
  1344. })
  1345. }
  1346. // UpdateProviderType sets the "provider_type" field to the value that was provided on create.
  1347. func (u *PendingAuthSessionUpsertBulk) UpdateProviderType() *PendingAuthSessionUpsertBulk {
  1348. return u.Update(func(s *PendingAuthSessionUpsert) {
  1349. s.UpdateProviderType()
  1350. })
  1351. }
  1352. // SetProviderKey sets the "provider_key" field.
  1353. func (u *PendingAuthSessionUpsertBulk) SetProviderKey(v string) *PendingAuthSessionUpsertBulk {
  1354. return u.Update(func(s *PendingAuthSessionUpsert) {
  1355. s.SetProviderKey(v)
  1356. })
  1357. }
  1358. // UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
  1359. func (u *PendingAuthSessionUpsertBulk) UpdateProviderKey() *PendingAuthSessionUpsertBulk {
  1360. return u.Update(func(s *PendingAuthSessionUpsert) {
  1361. s.UpdateProviderKey()
  1362. })
  1363. }
  1364. // SetProviderSubject sets the "provider_subject" field.
  1365. func (u *PendingAuthSessionUpsertBulk) SetProviderSubject(v string) *PendingAuthSessionUpsertBulk {
  1366. return u.Update(func(s *PendingAuthSessionUpsert) {
  1367. s.SetProviderSubject(v)
  1368. })
  1369. }
  1370. // UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
  1371. func (u *PendingAuthSessionUpsertBulk) UpdateProviderSubject() *PendingAuthSessionUpsertBulk {
  1372. return u.Update(func(s *PendingAuthSessionUpsert) {
  1373. s.UpdateProviderSubject()
  1374. })
  1375. }
  1376. // SetTargetUserID sets the "target_user_id" field.
  1377. func (u *PendingAuthSessionUpsertBulk) SetTargetUserID(v int64) *PendingAuthSessionUpsertBulk {
  1378. return u.Update(func(s *PendingAuthSessionUpsert) {
  1379. s.SetTargetUserID(v)
  1380. })
  1381. }
  1382. // UpdateTargetUserID sets the "target_user_id" field to the value that was provided on create.
  1383. func (u *PendingAuthSessionUpsertBulk) UpdateTargetUserID() *PendingAuthSessionUpsertBulk {
  1384. return u.Update(func(s *PendingAuthSessionUpsert) {
  1385. s.UpdateTargetUserID()
  1386. })
  1387. }
  1388. // ClearTargetUserID clears the value of the "target_user_id" field.
  1389. func (u *PendingAuthSessionUpsertBulk) ClearTargetUserID() *PendingAuthSessionUpsertBulk {
  1390. return u.Update(func(s *PendingAuthSessionUpsert) {
  1391. s.ClearTargetUserID()
  1392. })
  1393. }
  1394. // SetRedirectTo sets the "redirect_to" field.
  1395. func (u *PendingAuthSessionUpsertBulk) SetRedirectTo(v string) *PendingAuthSessionUpsertBulk {
  1396. return u.Update(func(s *PendingAuthSessionUpsert) {
  1397. s.SetRedirectTo(v)
  1398. })
  1399. }
  1400. // UpdateRedirectTo sets the "redirect_to" field to the value that was provided on create.
  1401. func (u *PendingAuthSessionUpsertBulk) UpdateRedirectTo() *PendingAuthSessionUpsertBulk {
  1402. return u.Update(func(s *PendingAuthSessionUpsert) {
  1403. s.UpdateRedirectTo()
  1404. })
  1405. }
  1406. // SetResolvedEmail sets the "resolved_email" field.
  1407. func (u *PendingAuthSessionUpsertBulk) SetResolvedEmail(v string) *PendingAuthSessionUpsertBulk {
  1408. return u.Update(func(s *PendingAuthSessionUpsert) {
  1409. s.SetResolvedEmail(v)
  1410. })
  1411. }
  1412. // UpdateResolvedEmail sets the "resolved_email" field to the value that was provided on create.
  1413. func (u *PendingAuthSessionUpsertBulk) UpdateResolvedEmail() *PendingAuthSessionUpsertBulk {
  1414. return u.Update(func(s *PendingAuthSessionUpsert) {
  1415. s.UpdateResolvedEmail()
  1416. })
  1417. }
  1418. // SetRegistrationPasswordHash sets the "registration_password_hash" field.
  1419. func (u *PendingAuthSessionUpsertBulk) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpsertBulk {
  1420. return u.Update(func(s *PendingAuthSessionUpsert) {
  1421. s.SetRegistrationPasswordHash(v)
  1422. })
  1423. }
  1424. // UpdateRegistrationPasswordHash sets the "registration_password_hash" field to the value that was provided on create.
  1425. func (u *PendingAuthSessionUpsertBulk) UpdateRegistrationPasswordHash() *PendingAuthSessionUpsertBulk {
  1426. return u.Update(func(s *PendingAuthSessionUpsert) {
  1427. s.UpdateRegistrationPasswordHash()
  1428. })
  1429. }
  1430. // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
  1431. func (u *PendingAuthSessionUpsertBulk) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpsertBulk {
  1432. return u.Update(func(s *PendingAuthSessionUpsert) {
  1433. s.SetUpstreamIdentityClaims(v)
  1434. })
  1435. }
  1436. // UpdateUpstreamIdentityClaims sets the "upstream_identity_claims" field to the value that was provided on create.
  1437. func (u *PendingAuthSessionUpsertBulk) UpdateUpstreamIdentityClaims() *PendingAuthSessionUpsertBulk {
  1438. return u.Update(func(s *PendingAuthSessionUpsert) {
  1439. s.UpdateUpstreamIdentityClaims()
  1440. })
  1441. }
  1442. // SetLocalFlowState sets the "local_flow_state" field.
  1443. func (u *PendingAuthSessionUpsertBulk) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpsertBulk {
  1444. return u.Update(func(s *PendingAuthSessionUpsert) {
  1445. s.SetLocalFlowState(v)
  1446. })
  1447. }
  1448. // UpdateLocalFlowState sets the "local_flow_state" field to the value that was provided on create.
  1449. func (u *PendingAuthSessionUpsertBulk) UpdateLocalFlowState() *PendingAuthSessionUpsertBulk {
  1450. return u.Update(func(s *PendingAuthSessionUpsert) {
  1451. s.UpdateLocalFlowState()
  1452. })
  1453. }
  1454. // SetBrowserSessionKey sets the "browser_session_key" field.
  1455. func (u *PendingAuthSessionUpsertBulk) SetBrowserSessionKey(v string) *PendingAuthSessionUpsertBulk {
  1456. return u.Update(func(s *PendingAuthSessionUpsert) {
  1457. s.SetBrowserSessionKey(v)
  1458. })
  1459. }
  1460. // UpdateBrowserSessionKey sets the "browser_session_key" field to the value that was provided on create.
  1461. func (u *PendingAuthSessionUpsertBulk) UpdateBrowserSessionKey() *PendingAuthSessionUpsertBulk {
  1462. return u.Update(func(s *PendingAuthSessionUpsert) {
  1463. s.UpdateBrowserSessionKey()
  1464. })
  1465. }
  1466. // SetCompletionCodeHash sets the "completion_code_hash" field.
  1467. func (u *PendingAuthSessionUpsertBulk) SetCompletionCodeHash(v string) *PendingAuthSessionUpsertBulk {
  1468. return u.Update(func(s *PendingAuthSessionUpsert) {
  1469. s.SetCompletionCodeHash(v)
  1470. })
  1471. }
  1472. // UpdateCompletionCodeHash sets the "completion_code_hash" field to the value that was provided on create.
  1473. func (u *PendingAuthSessionUpsertBulk) UpdateCompletionCodeHash() *PendingAuthSessionUpsertBulk {
  1474. return u.Update(func(s *PendingAuthSessionUpsert) {
  1475. s.UpdateCompletionCodeHash()
  1476. })
  1477. }
  1478. // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
  1479. func (u *PendingAuthSessionUpsertBulk) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1480. return u.Update(func(s *PendingAuthSessionUpsert) {
  1481. s.SetCompletionCodeExpiresAt(v)
  1482. })
  1483. }
  1484. // UpdateCompletionCodeExpiresAt sets the "completion_code_expires_at" field to the value that was provided on create.
  1485. func (u *PendingAuthSessionUpsertBulk) UpdateCompletionCodeExpiresAt() *PendingAuthSessionUpsertBulk {
  1486. return u.Update(func(s *PendingAuthSessionUpsert) {
  1487. s.UpdateCompletionCodeExpiresAt()
  1488. })
  1489. }
  1490. // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
  1491. func (u *PendingAuthSessionUpsertBulk) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpsertBulk {
  1492. return u.Update(func(s *PendingAuthSessionUpsert) {
  1493. s.ClearCompletionCodeExpiresAt()
  1494. })
  1495. }
  1496. // SetEmailVerifiedAt sets the "email_verified_at" field.
  1497. func (u *PendingAuthSessionUpsertBulk) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1498. return u.Update(func(s *PendingAuthSessionUpsert) {
  1499. s.SetEmailVerifiedAt(v)
  1500. })
  1501. }
  1502. // UpdateEmailVerifiedAt sets the "email_verified_at" field to the value that was provided on create.
  1503. func (u *PendingAuthSessionUpsertBulk) UpdateEmailVerifiedAt() *PendingAuthSessionUpsertBulk {
  1504. return u.Update(func(s *PendingAuthSessionUpsert) {
  1505. s.UpdateEmailVerifiedAt()
  1506. })
  1507. }
  1508. // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
  1509. func (u *PendingAuthSessionUpsertBulk) ClearEmailVerifiedAt() *PendingAuthSessionUpsertBulk {
  1510. return u.Update(func(s *PendingAuthSessionUpsert) {
  1511. s.ClearEmailVerifiedAt()
  1512. })
  1513. }
  1514. // SetPasswordVerifiedAt sets the "password_verified_at" field.
  1515. func (u *PendingAuthSessionUpsertBulk) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1516. return u.Update(func(s *PendingAuthSessionUpsert) {
  1517. s.SetPasswordVerifiedAt(v)
  1518. })
  1519. }
  1520. // UpdatePasswordVerifiedAt sets the "password_verified_at" field to the value that was provided on create.
  1521. func (u *PendingAuthSessionUpsertBulk) UpdatePasswordVerifiedAt() *PendingAuthSessionUpsertBulk {
  1522. return u.Update(func(s *PendingAuthSessionUpsert) {
  1523. s.UpdatePasswordVerifiedAt()
  1524. })
  1525. }
  1526. // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
  1527. func (u *PendingAuthSessionUpsertBulk) ClearPasswordVerifiedAt() *PendingAuthSessionUpsertBulk {
  1528. return u.Update(func(s *PendingAuthSessionUpsert) {
  1529. s.ClearPasswordVerifiedAt()
  1530. })
  1531. }
  1532. // SetTotpVerifiedAt sets the "totp_verified_at" field.
  1533. func (u *PendingAuthSessionUpsertBulk) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1534. return u.Update(func(s *PendingAuthSessionUpsert) {
  1535. s.SetTotpVerifiedAt(v)
  1536. })
  1537. }
  1538. // UpdateTotpVerifiedAt sets the "totp_verified_at" field to the value that was provided on create.
  1539. func (u *PendingAuthSessionUpsertBulk) UpdateTotpVerifiedAt() *PendingAuthSessionUpsertBulk {
  1540. return u.Update(func(s *PendingAuthSessionUpsert) {
  1541. s.UpdateTotpVerifiedAt()
  1542. })
  1543. }
  1544. // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
  1545. func (u *PendingAuthSessionUpsertBulk) ClearTotpVerifiedAt() *PendingAuthSessionUpsertBulk {
  1546. return u.Update(func(s *PendingAuthSessionUpsert) {
  1547. s.ClearTotpVerifiedAt()
  1548. })
  1549. }
  1550. // SetExpiresAt sets the "expires_at" field.
  1551. func (u *PendingAuthSessionUpsertBulk) SetExpiresAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1552. return u.Update(func(s *PendingAuthSessionUpsert) {
  1553. s.SetExpiresAt(v)
  1554. })
  1555. }
  1556. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  1557. func (u *PendingAuthSessionUpsertBulk) UpdateExpiresAt() *PendingAuthSessionUpsertBulk {
  1558. return u.Update(func(s *PendingAuthSessionUpsert) {
  1559. s.UpdateExpiresAt()
  1560. })
  1561. }
  1562. // SetConsumedAt sets the "consumed_at" field.
  1563. func (u *PendingAuthSessionUpsertBulk) SetConsumedAt(v time.Time) *PendingAuthSessionUpsertBulk {
  1564. return u.Update(func(s *PendingAuthSessionUpsert) {
  1565. s.SetConsumedAt(v)
  1566. })
  1567. }
  1568. // UpdateConsumedAt sets the "consumed_at" field to the value that was provided on create.
  1569. func (u *PendingAuthSessionUpsertBulk) UpdateConsumedAt() *PendingAuthSessionUpsertBulk {
  1570. return u.Update(func(s *PendingAuthSessionUpsert) {
  1571. s.UpdateConsumedAt()
  1572. })
  1573. }
  1574. // ClearConsumedAt clears the value of the "consumed_at" field.
  1575. func (u *PendingAuthSessionUpsertBulk) ClearConsumedAt() *PendingAuthSessionUpsertBulk {
  1576. return u.Update(func(s *PendingAuthSessionUpsert) {
  1577. s.ClearConsumedAt()
  1578. })
  1579. }
  1580. // Exec executes the query.
  1581. func (u *PendingAuthSessionUpsertBulk) Exec(ctx context.Context) error {
  1582. if u.create.err != nil {
  1583. return u.create.err
  1584. }
  1585. for i, b := range u.create.builders {
  1586. if len(b.conflict) != 0 {
  1587. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the PendingAuthSessionCreateBulk instead", i)
  1588. }
  1589. }
  1590. if len(u.create.conflict) == 0 {
  1591. return errors.New("ent: missing options for PendingAuthSessionCreateBulk.OnConflict")
  1592. }
  1593. return u.create.Exec(ctx)
  1594. }
  1595. // ExecX is like Exec, but panics if an error occurs.
  1596. func (u *PendingAuthSessionUpsertBulk) ExecX(ctx context.Context) {
  1597. if err := u.create.Exec(ctx); err != nil {
  1598. panic(err)
  1599. }
  1600. }