123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "sikey/w303a/http/internal/data/ent/child"
- "sikey/w303a/http/internal/data/ent/childref"
- "sikey/w303a/http/internal/data/ent/contacts"
- "sikey/w303a/http/internal/data/ent/device"
- "sikey/w303a/http/internal/data/ent/devicebind"
- "sikey/w303a/http/internal/data/ent/deviceconfig"
- "sikey/w303a/http/internal/data/ent/group"
- "sikey/w303a/http/internal/data/ent/member"
- "sikey/w303a/http/internal/data/ent/predicate"
- "sikey/w303a/http/internal/data/ent/user"
- "sync"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/google/uuid"
- )
- const (
- // Operation types.
- OpCreate = ent.OpCreate
- OpDelete = ent.OpDelete
- OpDeleteOne = ent.OpDeleteOne
- OpUpdate = ent.OpUpdate
- OpUpdateOne = ent.OpUpdateOne
- // Node types.
- TypeChild = "Child"
- TypeChildRef = "ChildRef"
- TypeContacts = "Contacts"
- TypeDevice = "Device"
- TypeDeviceBind = "DeviceBind"
- TypeDeviceConfig = "DeviceConfig"
- TypeGroup = "Group"
- TypeMember = "Member"
- TypeUser = "User"
- )
- // ChildMutation represents an operation that mutates the Child nodes in the graph.
- type ChildMutation struct {
- config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- child_name *string
- phone_number *string
- area_code *string
- avatar *string
- gender *int8
- addgender *int8
- height *int32
- addheight *int32
- weight *int32
- addweight *int32
- birthday *string
- is_enable_block_unknown_call *bool
- is_enable_fence *bool
- clearedFields map[string]struct{}
- childRefs map[int64]struct{}
- removedchildRefs map[int64]struct{}
- clearedchildRefs bool
- childDevice map[int64]struct{}
- removedchildDevice map[int64]struct{}
- clearedchildDevice bool
- childContacts map[int]struct{}
- removedchildContacts map[int]struct{}
- clearedchildContacts bool
- done bool
- oldValue func(context.Context) (*Child, error)
- predicates []predicate.Child
- }
- var _ ent.Mutation = (*ChildMutation)(nil)
- // childOption allows management of the mutation configuration using functional options.
- type childOption func(*ChildMutation)
- // newChildMutation creates new mutation for the Child entity.
- func newChildMutation(c config, op Op, opts ...childOption) *ChildMutation {
- m := &ChildMutation{
- config: c,
- op: op,
- typ: TypeChild,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChildID sets the ID field of the mutation.
- func withChildID(id uuid.UUID) childOption {
- return func(m *ChildMutation) {
- var (
- err error
- once sync.Once
- value *Child
- )
- m.oldValue = func(ctx context.Context) (*Child, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Child.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChild sets the old Child of the mutation.
- func withChild(node *Child) childOption {
- return func(m *ChildMutation) {
- m.oldValue = func(context.Context) (*Child, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChildMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChildMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of Child entities.
- func (m *ChildMutation) SetID(id uuid.UUID) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChildMutation) ID() (id uuid.UUID, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChildMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []uuid.UUID{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Child.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ChildMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ChildMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ChildMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ChildMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ChildMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ChildMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *ChildMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *ChildMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *ChildMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[child.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *ChildMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[child.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *ChildMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, child.FieldDeletedAt)
- }
- // SetChildName sets the "child_name" field.
- func (m *ChildMutation) SetChildName(s string) {
- m.child_name = &s
- }
- // ChildName returns the value of the "child_name" field in the mutation.
- func (m *ChildMutation) ChildName() (r string, exists bool) {
- v := m.child_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChildName returns the old "child_name" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldChildName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChildName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChildName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChildName: %w", err)
- }
- return oldValue.ChildName, nil
- }
- // ResetChildName resets all changes to the "child_name" field.
- func (m *ChildMutation) ResetChildName() {
- m.child_name = nil
- }
- // SetPhoneNumber sets the "phone_number" field.
- func (m *ChildMutation) SetPhoneNumber(s string) {
- m.phone_number = &s
- }
- // PhoneNumber returns the value of the "phone_number" field in the mutation.
- func (m *ChildMutation) PhoneNumber() (r string, exists bool) {
- v := m.phone_number
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPhoneNumber returns the old "phone_number" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldPhoneNumber(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPhoneNumber is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPhoneNumber requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPhoneNumber: %w", err)
- }
- return oldValue.PhoneNumber, nil
- }
- // ResetPhoneNumber resets all changes to the "phone_number" field.
- func (m *ChildMutation) ResetPhoneNumber() {
- m.phone_number = nil
- }
- // SetAreaCode sets the "area_code" field.
- func (m *ChildMutation) SetAreaCode(s string) {
- m.area_code = &s
- }
- // AreaCode returns the value of the "area_code" field in the mutation.
- func (m *ChildMutation) AreaCode() (r string, exists bool) {
- v := m.area_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAreaCode returns the old "area_code" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldAreaCode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAreaCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAreaCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAreaCode: %w", err)
- }
- return oldValue.AreaCode, nil
- }
- // ResetAreaCode resets all changes to the "area_code" field.
- func (m *ChildMutation) ResetAreaCode() {
- m.area_code = nil
- }
- // SetAvatar sets the "avatar" field.
- func (m *ChildMutation) SetAvatar(s string) {
- m.avatar = &s
- }
- // Avatar returns the value of the "avatar" field in the mutation.
- func (m *ChildMutation) Avatar() (r string, exists bool) {
- v := m.avatar
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAvatar returns the old "avatar" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldAvatar(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAvatar requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
- }
- return oldValue.Avatar, nil
- }
- // ClearAvatar clears the value of the "avatar" field.
- func (m *ChildMutation) ClearAvatar() {
- m.avatar = nil
- m.clearedFields[child.FieldAvatar] = struct{}{}
- }
- // AvatarCleared returns if the "avatar" field was cleared in this mutation.
- func (m *ChildMutation) AvatarCleared() bool {
- _, ok := m.clearedFields[child.FieldAvatar]
- return ok
- }
- // ResetAvatar resets all changes to the "avatar" field.
- func (m *ChildMutation) ResetAvatar() {
- m.avatar = nil
- delete(m.clearedFields, child.FieldAvatar)
- }
- // SetGender sets the "gender" field.
- func (m *ChildMutation) SetGender(i int8) {
- m.gender = &i
- m.addgender = nil
- }
- // Gender returns the value of the "gender" field in the mutation.
- func (m *ChildMutation) Gender() (r int8, exists bool) {
- v := m.gender
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGender returns the old "gender" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldGender(ctx context.Context) (v int8, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGender is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGender requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGender: %w", err)
- }
- return oldValue.Gender, nil
- }
- // AddGender adds i to the "gender" field.
- func (m *ChildMutation) AddGender(i int8) {
- if m.addgender != nil {
- *m.addgender += i
- } else {
- m.addgender = &i
- }
- }
- // AddedGender returns the value that was added to the "gender" field in this mutation.
- func (m *ChildMutation) AddedGender() (r int8, exists bool) {
- v := m.addgender
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetGender resets all changes to the "gender" field.
- func (m *ChildMutation) ResetGender() {
- m.gender = nil
- m.addgender = nil
- }
- // SetHeight sets the "height" field.
- func (m *ChildMutation) SetHeight(i int32) {
- m.height = &i
- m.addheight = nil
- }
- // Height returns the value of the "height" field in the mutation.
- func (m *ChildMutation) Height() (r int32, exists bool) {
- v := m.height
- if v == nil {
- return
- }
- return *v, true
- }
- // OldHeight returns the old "height" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldHeight(ctx context.Context) (v int32, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldHeight is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldHeight requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldHeight: %w", err)
- }
- return oldValue.Height, nil
- }
- // AddHeight adds i to the "height" field.
- func (m *ChildMutation) AddHeight(i int32) {
- if m.addheight != nil {
- *m.addheight += i
- } else {
- m.addheight = &i
- }
- }
- // AddedHeight returns the value that was added to the "height" field in this mutation.
- func (m *ChildMutation) AddedHeight() (r int32, exists bool) {
- v := m.addheight
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetHeight resets all changes to the "height" field.
- func (m *ChildMutation) ResetHeight() {
- m.height = nil
- m.addheight = nil
- }
- // SetWeight sets the "weight" field.
- func (m *ChildMutation) SetWeight(i int32) {
- m.weight = &i
- m.addweight = nil
- }
- // Weight returns the value of the "weight" field in the mutation.
- func (m *ChildMutation) Weight() (r int32, exists bool) {
- v := m.weight
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeight returns the old "weight" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldWeight(ctx context.Context) (v int32, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeight is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeight requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeight: %w", err)
- }
- return oldValue.Weight, nil
- }
- // AddWeight adds i to the "weight" field.
- func (m *ChildMutation) AddWeight(i int32) {
- if m.addweight != nil {
- *m.addweight += i
- } else {
- m.addweight = &i
- }
- }
- // AddedWeight returns the value that was added to the "weight" field in this mutation.
- func (m *ChildMutation) AddedWeight() (r int32, exists bool) {
- v := m.addweight
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetWeight resets all changes to the "weight" field.
- func (m *ChildMutation) ResetWeight() {
- m.weight = nil
- m.addweight = nil
- }
- // SetBirthday sets the "birthday" field.
- func (m *ChildMutation) SetBirthday(s string) {
- m.birthday = &s
- }
- // Birthday returns the value of the "birthday" field in the mutation.
- func (m *ChildMutation) Birthday() (r string, exists bool) {
- v := m.birthday
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBirthday returns the old "birthday" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldBirthday(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBirthday is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBirthday requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBirthday: %w", err)
- }
- return oldValue.Birthday, nil
- }
- // ClearBirthday clears the value of the "birthday" field.
- func (m *ChildMutation) ClearBirthday() {
- m.birthday = nil
- m.clearedFields[child.FieldBirthday] = struct{}{}
- }
- // BirthdayCleared returns if the "birthday" field was cleared in this mutation.
- func (m *ChildMutation) BirthdayCleared() bool {
- _, ok := m.clearedFields[child.FieldBirthday]
- return ok
- }
- // ResetBirthday resets all changes to the "birthday" field.
- func (m *ChildMutation) ResetBirthday() {
- m.birthday = nil
- delete(m.clearedFields, child.FieldBirthday)
- }
- // SetIsEnableBlockUnknownCall sets the "is_enable_block_unknown_call" field.
- func (m *ChildMutation) SetIsEnableBlockUnknownCall(b bool) {
- m.is_enable_block_unknown_call = &b
- }
- // IsEnableBlockUnknownCall returns the value of the "is_enable_block_unknown_call" field in the mutation.
- func (m *ChildMutation) IsEnableBlockUnknownCall() (r bool, exists bool) {
- v := m.is_enable_block_unknown_call
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIsEnableBlockUnknownCall returns the old "is_enable_block_unknown_call" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldIsEnableBlockUnknownCall(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIsEnableBlockUnknownCall is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIsEnableBlockUnknownCall requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIsEnableBlockUnknownCall: %w", err)
- }
- return oldValue.IsEnableBlockUnknownCall, nil
- }
- // ResetIsEnableBlockUnknownCall resets all changes to the "is_enable_block_unknown_call" field.
- func (m *ChildMutation) ResetIsEnableBlockUnknownCall() {
- m.is_enable_block_unknown_call = nil
- }
- // SetIsEnableFence sets the "is_enable_fence" field.
- func (m *ChildMutation) SetIsEnableFence(b bool) {
- m.is_enable_fence = &b
- }
- // IsEnableFence returns the value of the "is_enable_fence" field in the mutation.
- func (m *ChildMutation) IsEnableFence() (r bool, exists bool) {
- v := m.is_enable_fence
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIsEnableFence returns the old "is_enable_fence" field's value of the Child entity.
- // If the Child object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildMutation) OldIsEnableFence(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIsEnableFence is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIsEnableFence requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIsEnableFence: %w", err)
- }
- return oldValue.IsEnableFence, nil
- }
- // ResetIsEnableFence resets all changes to the "is_enable_fence" field.
- func (m *ChildMutation) ResetIsEnableFence() {
- m.is_enable_fence = nil
- }
- // AddChildRefIDs adds the "childRefs" edge to the ChildRef entity by ids.
- func (m *ChildMutation) AddChildRefIDs(ids ...int64) {
- if m.childRefs == nil {
- m.childRefs = make(map[int64]struct{})
- }
- for i := range ids {
- m.childRefs[ids[i]] = struct{}{}
- }
- }
- // ClearChildRefs clears the "childRefs" edge to the ChildRef entity.
- func (m *ChildMutation) ClearChildRefs() {
- m.clearedchildRefs = true
- }
- // ChildRefsCleared reports if the "childRefs" edge to the ChildRef entity was cleared.
- func (m *ChildMutation) ChildRefsCleared() bool {
- return m.clearedchildRefs
- }
- // RemoveChildRefIDs removes the "childRefs" edge to the ChildRef entity by IDs.
- func (m *ChildMutation) RemoveChildRefIDs(ids ...int64) {
- if m.removedchildRefs == nil {
- m.removedchildRefs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.childRefs, ids[i])
- m.removedchildRefs[ids[i]] = struct{}{}
- }
- }
- // RemovedChildRefs returns the removed IDs of the "childRefs" edge to the ChildRef entity.
- func (m *ChildMutation) RemovedChildRefsIDs() (ids []int64) {
- for id := range m.removedchildRefs {
- ids = append(ids, id)
- }
- return
- }
- // ChildRefsIDs returns the "childRefs" edge IDs in the mutation.
- func (m *ChildMutation) ChildRefsIDs() (ids []int64) {
- for id := range m.childRefs {
- ids = append(ids, id)
- }
- return
- }
- // ResetChildRefs resets all changes to the "childRefs" edge.
- func (m *ChildMutation) ResetChildRefs() {
- m.childRefs = nil
- m.clearedchildRefs = false
- m.removedchildRefs = nil
- }
- // AddChildDeviceIDs adds the "childDevice" edge to the DeviceBind entity by ids.
- func (m *ChildMutation) AddChildDeviceIDs(ids ...int64) {
- if m.childDevice == nil {
- m.childDevice = make(map[int64]struct{})
- }
- for i := range ids {
- m.childDevice[ids[i]] = struct{}{}
- }
- }
- // ClearChildDevice clears the "childDevice" edge to the DeviceBind entity.
- func (m *ChildMutation) ClearChildDevice() {
- m.clearedchildDevice = true
- }
- // ChildDeviceCleared reports if the "childDevice" edge to the DeviceBind entity was cleared.
- func (m *ChildMutation) ChildDeviceCleared() bool {
- return m.clearedchildDevice
- }
- // RemoveChildDeviceIDs removes the "childDevice" edge to the DeviceBind entity by IDs.
- func (m *ChildMutation) RemoveChildDeviceIDs(ids ...int64) {
- if m.removedchildDevice == nil {
- m.removedchildDevice = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.childDevice, ids[i])
- m.removedchildDevice[ids[i]] = struct{}{}
- }
- }
- // RemovedChildDevice returns the removed IDs of the "childDevice" edge to the DeviceBind entity.
- func (m *ChildMutation) RemovedChildDeviceIDs() (ids []int64) {
- for id := range m.removedchildDevice {
- ids = append(ids, id)
- }
- return
- }
- // ChildDeviceIDs returns the "childDevice" edge IDs in the mutation.
- func (m *ChildMutation) ChildDeviceIDs() (ids []int64) {
- for id := range m.childDevice {
- ids = append(ids, id)
- }
- return
- }
- // ResetChildDevice resets all changes to the "childDevice" edge.
- func (m *ChildMutation) ResetChildDevice() {
- m.childDevice = nil
- m.clearedchildDevice = false
- m.removedchildDevice = nil
- }
- // AddChildContactIDs adds the "childContacts" edge to the Contacts entity by ids.
- func (m *ChildMutation) AddChildContactIDs(ids ...int) {
- if m.childContacts == nil {
- m.childContacts = make(map[int]struct{})
- }
- for i := range ids {
- m.childContacts[ids[i]] = struct{}{}
- }
- }
- // ClearChildContacts clears the "childContacts" edge to the Contacts entity.
- func (m *ChildMutation) ClearChildContacts() {
- m.clearedchildContacts = true
- }
- // ChildContactsCleared reports if the "childContacts" edge to the Contacts entity was cleared.
- func (m *ChildMutation) ChildContactsCleared() bool {
- return m.clearedchildContacts
- }
- // RemoveChildContactIDs removes the "childContacts" edge to the Contacts entity by IDs.
- func (m *ChildMutation) RemoveChildContactIDs(ids ...int) {
- if m.removedchildContacts == nil {
- m.removedchildContacts = make(map[int]struct{})
- }
- for i := range ids {
- delete(m.childContacts, ids[i])
- m.removedchildContacts[ids[i]] = struct{}{}
- }
- }
- // RemovedChildContacts returns the removed IDs of the "childContacts" edge to the Contacts entity.
- func (m *ChildMutation) RemovedChildContactsIDs() (ids []int) {
- for id := range m.removedchildContacts {
- ids = append(ids, id)
- }
- return
- }
- // ChildContactsIDs returns the "childContacts" edge IDs in the mutation.
- func (m *ChildMutation) ChildContactsIDs() (ids []int) {
- for id := range m.childContacts {
- ids = append(ids, id)
- }
- return
- }
- // ResetChildContacts resets all changes to the "childContacts" edge.
- func (m *ChildMutation) ResetChildContacts() {
- m.childContacts = nil
- m.clearedchildContacts = false
- m.removedchildContacts = nil
- }
- // Where appends a list predicates to the ChildMutation builder.
- func (m *ChildMutation) Where(ps ...predicate.Child) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChildMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChildMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Child, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChildMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChildMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Child).
- func (m *ChildMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChildMutation) Fields() []string {
- fields := make([]string, 0, 13)
- if m.created_at != nil {
- fields = append(fields, child.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, child.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, child.FieldDeletedAt)
- }
- if m.child_name != nil {
- fields = append(fields, child.FieldChildName)
- }
- if m.phone_number != nil {
- fields = append(fields, child.FieldPhoneNumber)
- }
- if m.area_code != nil {
- fields = append(fields, child.FieldAreaCode)
- }
- if m.avatar != nil {
- fields = append(fields, child.FieldAvatar)
- }
- if m.gender != nil {
- fields = append(fields, child.FieldGender)
- }
- if m.height != nil {
- fields = append(fields, child.FieldHeight)
- }
- if m.weight != nil {
- fields = append(fields, child.FieldWeight)
- }
- if m.birthday != nil {
- fields = append(fields, child.FieldBirthday)
- }
- if m.is_enable_block_unknown_call != nil {
- fields = append(fields, child.FieldIsEnableBlockUnknownCall)
- }
- if m.is_enable_fence != nil {
- fields = append(fields, child.FieldIsEnableFence)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChildMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case child.FieldCreatedAt:
- return m.CreatedAt()
- case child.FieldUpdatedAt:
- return m.UpdatedAt()
- case child.FieldDeletedAt:
- return m.DeletedAt()
- case child.FieldChildName:
- return m.ChildName()
- case child.FieldPhoneNumber:
- return m.PhoneNumber()
- case child.FieldAreaCode:
- return m.AreaCode()
- case child.FieldAvatar:
- return m.Avatar()
- case child.FieldGender:
- return m.Gender()
- case child.FieldHeight:
- return m.Height()
- case child.FieldWeight:
- return m.Weight()
- case child.FieldBirthday:
- return m.Birthday()
- case child.FieldIsEnableBlockUnknownCall:
- return m.IsEnableBlockUnknownCall()
- case child.FieldIsEnableFence:
- return m.IsEnableFence()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChildMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case child.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case child.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case child.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case child.FieldChildName:
- return m.OldChildName(ctx)
- case child.FieldPhoneNumber:
- return m.OldPhoneNumber(ctx)
- case child.FieldAreaCode:
- return m.OldAreaCode(ctx)
- case child.FieldAvatar:
- return m.OldAvatar(ctx)
- case child.FieldGender:
- return m.OldGender(ctx)
- case child.FieldHeight:
- return m.OldHeight(ctx)
- case child.FieldWeight:
- return m.OldWeight(ctx)
- case child.FieldBirthday:
- return m.OldBirthday(ctx)
- case child.FieldIsEnableBlockUnknownCall:
- return m.OldIsEnableBlockUnknownCall(ctx)
- case child.FieldIsEnableFence:
- return m.OldIsEnableFence(ctx)
- }
- return nil, fmt.Errorf("unknown Child field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChildMutation) SetField(name string, value ent.Value) error {
- switch name {
- case child.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case child.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case child.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case child.FieldChildName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChildName(v)
- return nil
- case child.FieldPhoneNumber:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPhoneNumber(v)
- return nil
- case child.FieldAreaCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAreaCode(v)
- return nil
- case child.FieldAvatar:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAvatar(v)
- return nil
- case child.FieldGender:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGender(v)
- return nil
- case child.FieldHeight:
- v, ok := value.(int32)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetHeight(v)
- return nil
- case child.FieldWeight:
- v, ok := value.(int32)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeight(v)
- return nil
- case child.FieldBirthday:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBirthday(v)
- return nil
- case child.FieldIsEnableBlockUnknownCall:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIsEnableBlockUnknownCall(v)
- return nil
- case child.FieldIsEnableFence:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIsEnableFence(v)
- return nil
- }
- return fmt.Errorf("unknown Child field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChildMutation) AddedFields() []string {
- var fields []string
- if m.addgender != nil {
- fields = append(fields, child.FieldGender)
- }
- if m.addheight != nil {
- fields = append(fields, child.FieldHeight)
- }
- if m.addweight != nil {
- fields = append(fields, child.FieldWeight)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChildMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case child.FieldGender:
- return m.AddedGender()
- case child.FieldHeight:
- return m.AddedHeight()
- case child.FieldWeight:
- return m.AddedWeight()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChildMutation) AddField(name string, value ent.Value) error {
- switch name {
- case child.FieldGender:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddGender(v)
- return nil
- case child.FieldHeight:
- v, ok := value.(int32)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddHeight(v)
- return nil
- case child.FieldWeight:
- v, ok := value.(int32)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWeight(v)
- return nil
- }
- return fmt.Errorf("unknown Child numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChildMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(child.FieldDeletedAt) {
- fields = append(fields, child.FieldDeletedAt)
- }
- if m.FieldCleared(child.FieldAvatar) {
- fields = append(fields, child.FieldAvatar)
- }
- if m.FieldCleared(child.FieldBirthday) {
- fields = append(fields, child.FieldBirthday)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChildMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChildMutation) ClearField(name string) error {
- switch name {
- case child.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case child.FieldAvatar:
- m.ClearAvatar()
- return nil
- case child.FieldBirthday:
- m.ClearBirthday()
- return nil
- }
- return fmt.Errorf("unknown Child nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChildMutation) ResetField(name string) error {
- switch name {
- case child.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case child.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case child.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case child.FieldChildName:
- m.ResetChildName()
- return nil
- case child.FieldPhoneNumber:
- m.ResetPhoneNumber()
- return nil
- case child.FieldAreaCode:
- m.ResetAreaCode()
- return nil
- case child.FieldAvatar:
- m.ResetAvatar()
- return nil
- case child.FieldGender:
- m.ResetGender()
- return nil
- case child.FieldHeight:
- m.ResetHeight()
- return nil
- case child.FieldWeight:
- m.ResetWeight()
- return nil
- case child.FieldBirthday:
- m.ResetBirthday()
- return nil
- case child.FieldIsEnableBlockUnknownCall:
- m.ResetIsEnableBlockUnknownCall()
- return nil
- case child.FieldIsEnableFence:
- m.ResetIsEnableFence()
- return nil
- }
- return fmt.Errorf("unknown Child field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChildMutation) AddedEdges() []string {
- edges := make([]string, 0, 3)
- if m.childRefs != nil {
- edges = append(edges, child.EdgeChildRefs)
- }
- if m.childDevice != nil {
- edges = append(edges, child.EdgeChildDevice)
- }
- if m.childContacts != nil {
- edges = append(edges, child.EdgeChildContacts)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChildMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case child.EdgeChildRefs:
- ids := make([]ent.Value, 0, len(m.childRefs))
- for id := range m.childRefs {
- ids = append(ids, id)
- }
- return ids
- case child.EdgeChildDevice:
- ids := make([]ent.Value, 0, len(m.childDevice))
- for id := range m.childDevice {
- ids = append(ids, id)
- }
- return ids
- case child.EdgeChildContacts:
- ids := make([]ent.Value, 0, len(m.childContacts))
- for id := range m.childContacts {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChildMutation) RemovedEdges() []string {
- edges := make([]string, 0, 3)
- if m.removedchildRefs != nil {
- edges = append(edges, child.EdgeChildRefs)
- }
- if m.removedchildDevice != nil {
- edges = append(edges, child.EdgeChildDevice)
- }
- if m.removedchildContacts != nil {
- edges = append(edges, child.EdgeChildContacts)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChildMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case child.EdgeChildRefs:
- ids := make([]ent.Value, 0, len(m.removedchildRefs))
- for id := range m.removedchildRefs {
- ids = append(ids, id)
- }
- return ids
- case child.EdgeChildDevice:
- ids := make([]ent.Value, 0, len(m.removedchildDevice))
- for id := range m.removedchildDevice {
- ids = append(ids, id)
- }
- return ids
- case child.EdgeChildContacts:
- ids := make([]ent.Value, 0, len(m.removedchildContacts))
- for id := range m.removedchildContacts {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChildMutation) ClearedEdges() []string {
- edges := make([]string, 0, 3)
- if m.clearedchildRefs {
- edges = append(edges, child.EdgeChildRefs)
- }
- if m.clearedchildDevice {
- edges = append(edges, child.EdgeChildDevice)
- }
- if m.clearedchildContacts {
- edges = append(edges, child.EdgeChildContacts)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChildMutation) EdgeCleared(name string) bool {
- switch name {
- case child.EdgeChildRefs:
- return m.clearedchildRefs
- case child.EdgeChildDevice:
- return m.clearedchildDevice
- case child.EdgeChildContacts:
- return m.clearedchildContacts
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChildMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown Child unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChildMutation) ResetEdge(name string) error {
- switch name {
- case child.EdgeChildRefs:
- m.ResetChildRefs()
- return nil
- case child.EdgeChildDevice:
- m.ResetChildDevice()
- return nil
- case child.EdgeChildContacts:
- m.ResetChildContacts()
- return nil
- }
- return fmt.Errorf("unknown Child edge %s", name)
- }
- // ChildRefMutation represents an operation that mutates the ChildRef nodes in the graph.
- type ChildRefMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- clearedFields map[string]struct{}
- child *uuid.UUID
- clearedchild bool
- user *uuid.UUID
- cleareduser bool
- done bool
- oldValue func(context.Context) (*ChildRef, error)
- predicates []predicate.ChildRef
- }
- var _ ent.Mutation = (*ChildRefMutation)(nil)
- // childrefOption allows management of the mutation configuration using functional options.
- type childrefOption func(*ChildRefMutation)
- // newChildRefMutation creates new mutation for the ChildRef entity.
- func newChildRefMutation(c config, op Op, opts ...childrefOption) *ChildRefMutation {
- m := &ChildRefMutation{
- config: c,
- op: op,
- typ: TypeChildRef,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChildRefID sets the ID field of the mutation.
- func withChildRefID(id int64) childrefOption {
- return func(m *ChildRefMutation) {
- var (
- err error
- once sync.Once
- value *ChildRef
- )
- m.oldValue = func(ctx context.Context) (*ChildRef, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ChildRef.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChildRef sets the old ChildRef of the mutation.
- func withChildRef(node *ChildRef) childrefOption {
- return func(m *ChildRefMutation) {
- m.oldValue = func(context.Context) (*ChildRef, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChildRefMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChildRefMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of ChildRef entities.
- func (m *ChildRefMutation) SetID(id int64) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChildRefMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChildRefMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ChildRef.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ChildRefMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ChildRefMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the ChildRef entity.
- // If the ChildRef object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildRefMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ChildRefMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ChildRefMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ChildRefMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the ChildRef entity.
- // If the ChildRef object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildRefMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ChildRefMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *ChildRefMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *ChildRefMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the ChildRef entity.
- // If the ChildRef object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildRefMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *ChildRefMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[childref.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *ChildRefMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[childref.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *ChildRefMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, childref.FieldDeletedAt)
- }
- // SetUserID sets the "user_id" field.
- func (m *ChildRefMutation) SetUserID(u uuid.UUID) {
- m.user = &u
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *ChildRefMutation) UserID() (r uuid.UUID, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the ChildRef entity.
- // If the ChildRef object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildRefMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ClearUserID clears the value of the "user_id" field.
- func (m *ChildRefMutation) ClearUserID() {
- m.user = nil
- m.clearedFields[childref.FieldUserID] = struct{}{}
- }
- // UserIDCleared returns if the "user_id" field was cleared in this mutation.
- func (m *ChildRefMutation) UserIDCleared() bool {
- _, ok := m.clearedFields[childref.FieldUserID]
- return ok
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *ChildRefMutation) ResetUserID() {
- m.user = nil
- delete(m.clearedFields, childref.FieldUserID)
- }
- // SetChildID sets the "child_id" field.
- func (m *ChildRefMutation) SetChildID(u uuid.UUID) {
- m.child = &u
- }
- // ChildID returns the value of the "child_id" field in the mutation.
- func (m *ChildRefMutation) ChildID() (r uuid.UUID, exists bool) {
- v := m.child
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChildID returns the old "child_id" field's value of the ChildRef entity.
- // If the ChildRef object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChildRefMutation) OldChildID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChildID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChildID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChildID: %w", err)
- }
- return oldValue.ChildID, nil
- }
- // ClearChildID clears the value of the "child_id" field.
- func (m *ChildRefMutation) ClearChildID() {
- m.child = nil
- m.clearedFields[childref.FieldChildID] = struct{}{}
- }
- // ChildIDCleared returns if the "child_id" field was cleared in this mutation.
- func (m *ChildRefMutation) ChildIDCleared() bool {
- _, ok := m.clearedFields[childref.FieldChildID]
- return ok
- }
- // ResetChildID resets all changes to the "child_id" field.
- func (m *ChildRefMutation) ResetChildID() {
- m.child = nil
- delete(m.clearedFields, childref.FieldChildID)
- }
- // ClearChild clears the "child" edge to the Child entity.
- func (m *ChildRefMutation) ClearChild() {
- m.clearedchild = true
- m.clearedFields[childref.FieldChildID] = struct{}{}
- }
- // ChildCleared reports if the "child" edge to the Child entity was cleared.
- func (m *ChildRefMutation) ChildCleared() bool {
- return m.ChildIDCleared() || m.clearedchild
- }
- // ChildIDs returns the "child" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // ChildID instead. It exists only for internal usage by the builders.
- func (m *ChildRefMutation) ChildIDs() (ids []uuid.UUID) {
- if id := m.child; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetChild resets all changes to the "child" edge.
- func (m *ChildRefMutation) ResetChild() {
- m.child = nil
- m.clearedchild = false
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *ChildRefMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[childref.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *ChildRefMutation) UserCleared() bool {
- return m.UserIDCleared() || m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *ChildRefMutation) UserIDs() (ids []uuid.UUID) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *ChildRefMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // Where appends a list predicates to the ChildRefMutation builder.
- func (m *ChildRefMutation) Where(ps ...predicate.ChildRef) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChildRefMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChildRefMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ChildRef, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChildRefMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChildRefMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ChildRef).
- func (m *ChildRefMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChildRefMutation) Fields() []string {
- fields := make([]string, 0, 5)
- if m.created_at != nil {
- fields = append(fields, childref.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, childref.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, childref.FieldDeletedAt)
- }
- if m.user != nil {
- fields = append(fields, childref.FieldUserID)
- }
- if m.child != nil {
- fields = append(fields, childref.FieldChildID)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChildRefMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case childref.FieldCreatedAt:
- return m.CreatedAt()
- case childref.FieldUpdatedAt:
- return m.UpdatedAt()
- case childref.FieldDeletedAt:
- return m.DeletedAt()
- case childref.FieldUserID:
- return m.UserID()
- case childref.FieldChildID:
- return m.ChildID()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChildRefMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case childref.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case childref.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case childref.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case childref.FieldUserID:
- return m.OldUserID(ctx)
- case childref.FieldChildID:
- return m.OldChildID(ctx)
- }
- return nil, fmt.Errorf("unknown ChildRef field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChildRefMutation) SetField(name string, value ent.Value) error {
- switch name {
- case childref.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case childref.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case childref.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case childref.FieldUserID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case childref.FieldChildID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChildID(v)
- return nil
- }
- return fmt.Errorf("unknown ChildRef field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChildRefMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChildRefMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChildRefMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown ChildRef numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChildRefMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(childref.FieldDeletedAt) {
- fields = append(fields, childref.FieldDeletedAt)
- }
- if m.FieldCleared(childref.FieldUserID) {
- fields = append(fields, childref.FieldUserID)
- }
- if m.FieldCleared(childref.FieldChildID) {
- fields = append(fields, childref.FieldChildID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChildRefMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChildRefMutation) ClearField(name string) error {
- switch name {
- case childref.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case childref.FieldUserID:
- m.ClearUserID()
- return nil
- case childref.FieldChildID:
- m.ClearChildID()
- return nil
- }
- return fmt.Errorf("unknown ChildRef nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChildRefMutation) ResetField(name string) error {
- switch name {
- case childref.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case childref.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case childref.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case childref.FieldUserID:
- m.ResetUserID()
- return nil
- case childref.FieldChildID:
- m.ResetChildID()
- return nil
- }
- return fmt.Errorf("unknown ChildRef field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChildRefMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.child != nil {
- edges = append(edges, childref.EdgeChild)
- }
- if m.user != nil {
- edges = append(edges, childref.EdgeUser)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChildRefMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case childref.EdgeChild:
- if id := m.child; id != nil {
- return []ent.Value{*id}
- }
- case childref.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChildRefMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChildRefMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChildRefMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedchild {
- edges = append(edges, childref.EdgeChild)
- }
- if m.cleareduser {
- edges = append(edges, childref.EdgeUser)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChildRefMutation) EdgeCleared(name string) bool {
- switch name {
- case childref.EdgeChild:
- return m.clearedchild
- case childref.EdgeUser:
- return m.cleareduser
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChildRefMutation) ClearEdge(name string) error {
- switch name {
- case childref.EdgeChild:
- m.ClearChild()
- return nil
- case childref.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown ChildRef unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChildRefMutation) ResetEdge(name string) error {
- switch name {
- case childref.EdgeChild:
- m.ResetChild()
- return nil
- case childref.EdgeUser:
- m.ResetUser()
- return nil
- }
- return fmt.Errorf("unknown ChildRef edge %s", name)
- }
- // ContactsMutation represents an operation that mutates the Contacts nodes in the graph.
- type ContactsMutation struct {
- config
- op Op
- typ string
- id *int
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- ref_id *uuid.UUID
- ref_type *contacts.RefType
- remark_name *string
- remark_avatar *string
- clearedFields map[string]struct{}
- child *uuid.UUID
- clearedchild bool
- done bool
- oldValue func(context.Context) (*Contacts, error)
- predicates []predicate.Contacts
- }
- var _ ent.Mutation = (*ContactsMutation)(nil)
- // contactsOption allows management of the mutation configuration using functional options.
- type contactsOption func(*ContactsMutation)
- // newContactsMutation creates new mutation for the Contacts entity.
- func newContactsMutation(c config, op Op, opts ...contactsOption) *ContactsMutation {
- m := &ContactsMutation{
- config: c,
- op: op,
- typ: TypeContacts,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withContactsID sets the ID field of the mutation.
- func withContactsID(id int) contactsOption {
- return func(m *ContactsMutation) {
- var (
- err error
- once sync.Once
- value *Contacts
- )
- m.oldValue = func(ctx context.Context) (*Contacts, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Contacts.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withContacts sets the old Contacts of the mutation.
- func withContacts(node *Contacts) contactsOption {
- return func(m *ContactsMutation) {
- m.oldValue = func(context.Context) (*Contacts, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ContactsMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ContactsMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ContactsMutation) ID() (id int, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ContactsMutation) IDs(ctx context.Context) ([]int, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Contacts.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ContactsMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ContactsMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ContactsMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ContactsMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ContactsMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ContactsMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *ContactsMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *ContactsMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *ContactsMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[contacts.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *ContactsMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[contacts.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *ContactsMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, contacts.FieldDeletedAt)
- }
- // SetChildID sets the "child_id" field.
- func (m *ContactsMutation) SetChildID(u uuid.UUID) {
- m.child = &u
- }
- // ChildID returns the value of the "child_id" field in the mutation.
- func (m *ContactsMutation) ChildID() (r uuid.UUID, exists bool) {
- v := m.child
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChildID returns the old "child_id" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldChildID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChildID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChildID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChildID: %w", err)
- }
- return oldValue.ChildID, nil
- }
- // ClearChildID clears the value of the "child_id" field.
- func (m *ContactsMutation) ClearChildID() {
- m.child = nil
- m.clearedFields[contacts.FieldChildID] = struct{}{}
- }
- // ChildIDCleared returns if the "child_id" field was cleared in this mutation.
- func (m *ContactsMutation) ChildIDCleared() bool {
- _, ok := m.clearedFields[contacts.FieldChildID]
- return ok
- }
- // ResetChildID resets all changes to the "child_id" field.
- func (m *ContactsMutation) ResetChildID() {
- m.child = nil
- delete(m.clearedFields, contacts.FieldChildID)
- }
- // SetRefID sets the "ref_id" field.
- func (m *ContactsMutation) SetRefID(u uuid.UUID) {
- m.ref_id = &u
- }
- // RefID returns the value of the "ref_id" field in the mutation.
- func (m *ContactsMutation) RefID() (r uuid.UUID, exists bool) {
- v := m.ref_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefID returns the old "ref_id" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldRefID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefID: %w", err)
- }
- return oldValue.RefID, nil
- }
- // ResetRefID resets all changes to the "ref_id" field.
- func (m *ContactsMutation) ResetRefID() {
- m.ref_id = nil
- }
- // SetRefType sets the "ref_type" field.
- func (m *ContactsMutation) SetRefType(ct contacts.RefType) {
- m.ref_type = &ct
- }
- // RefType returns the value of the "ref_type" field in the mutation.
- func (m *ContactsMutation) RefType() (r contacts.RefType, exists bool) {
- v := m.ref_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefType returns the old "ref_type" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldRefType(ctx context.Context) (v contacts.RefType, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefType: %w", err)
- }
- return oldValue.RefType, nil
- }
- // ResetRefType resets all changes to the "ref_type" field.
- func (m *ContactsMutation) ResetRefType() {
- m.ref_type = nil
- }
- // SetRemarkName sets the "remark_name" field.
- func (m *ContactsMutation) SetRemarkName(s string) {
- m.remark_name = &s
- }
- // RemarkName returns the value of the "remark_name" field in the mutation.
- func (m *ContactsMutation) RemarkName() (r string, exists bool) {
- v := m.remark_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRemarkName returns the old "remark_name" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldRemarkName(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRemarkName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRemarkName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRemarkName: %w", err)
- }
- return oldValue.RemarkName, nil
- }
- // ClearRemarkName clears the value of the "remark_name" field.
- func (m *ContactsMutation) ClearRemarkName() {
- m.remark_name = nil
- m.clearedFields[contacts.FieldRemarkName] = struct{}{}
- }
- // RemarkNameCleared returns if the "remark_name" field was cleared in this mutation.
- func (m *ContactsMutation) RemarkNameCleared() bool {
- _, ok := m.clearedFields[contacts.FieldRemarkName]
- return ok
- }
- // ResetRemarkName resets all changes to the "remark_name" field.
- func (m *ContactsMutation) ResetRemarkName() {
- m.remark_name = nil
- delete(m.clearedFields, contacts.FieldRemarkName)
- }
- // SetRemarkAvatar sets the "remark_avatar" field.
- func (m *ContactsMutation) SetRemarkAvatar(s string) {
- m.remark_avatar = &s
- }
- // RemarkAvatar returns the value of the "remark_avatar" field in the mutation.
- func (m *ContactsMutation) RemarkAvatar() (r string, exists bool) {
- v := m.remark_avatar
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRemarkAvatar returns the old "remark_avatar" field's value of the Contacts entity.
- // If the Contacts object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ContactsMutation) OldRemarkAvatar(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRemarkAvatar is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRemarkAvatar requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRemarkAvatar: %w", err)
- }
- return oldValue.RemarkAvatar, nil
- }
- // ClearRemarkAvatar clears the value of the "remark_avatar" field.
- func (m *ContactsMutation) ClearRemarkAvatar() {
- m.remark_avatar = nil
- m.clearedFields[contacts.FieldRemarkAvatar] = struct{}{}
- }
- // RemarkAvatarCleared returns if the "remark_avatar" field was cleared in this mutation.
- func (m *ContactsMutation) RemarkAvatarCleared() bool {
- _, ok := m.clearedFields[contacts.FieldRemarkAvatar]
- return ok
- }
- // ResetRemarkAvatar resets all changes to the "remark_avatar" field.
- func (m *ContactsMutation) ResetRemarkAvatar() {
- m.remark_avatar = nil
- delete(m.clearedFields, contacts.FieldRemarkAvatar)
- }
- // ClearChild clears the "child" edge to the Child entity.
- func (m *ContactsMutation) ClearChild() {
- m.clearedchild = true
- m.clearedFields[contacts.FieldChildID] = struct{}{}
- }
- // ChildCleared reports if the "child" edge to the Child entity was cleared.
- func (m *ContactsMutation) ChildCleared() bool {
- return m.ChildIDCleared() || m.clearedchild
- }
- // ChildIDs returns the "child" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // ChildID instead. It exists only for internal usage by the builders.
- func (m *ContactsMutation) ChildIDs() (ids []uuid.UUID) {
- if id := m.child; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetChild resets all changes to the "child" edge.
- func (m *ContactsMutation) ResetChild() {
- m.child = nil
- m.clearedchild = false
- }
- // Where appends a list predicates to the ContactsMutation builder.
- func (m *ContactsMutation) Where(ps ...predicate.Contacts) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ContactsMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ContactsMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Contacts, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ContactsMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ContactsMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Contacts).
- func (m *ContactsMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ContactsMutation) Fields() []string {
- fields := make([]string, 0, 8)
- if m.created_at != nil {
- fields = append(fields, contacts.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, contacts.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, contacts.FieldDeletedAt)
- }
- if m.child != nil {
- fields = append(fields, contacts.FieldChildID)
- }
- if m.ref_id != nil {
- fields = append(fields, contacts.FieldRefID)
- }
- if m.ref_type != nil {
- fields = append(fields, contacts.FieldRefType)
- }
- if m.remark_name != nil {
- fields = append(fields, contacts.FieldRemarkName)
- }
- if m.remark_avatar != nil {
- fields = append(fields, contacts.FieldRemarkAvatar)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ContactsMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case contacts.FieldCreatedAt:
- return m.CreatedAt()
- case contacts.FieldUpdatedAt:
- return m.UpdatedAt()
- case contacts.FieldDeletedAt:
- return m.DeletedAt()
- case contacts.FieldChildID:
- return m.ChildID()
- case contacts.FieldRefID:
- return m.RefID()
- case contacts.FieldRefType:
- return m.RefType()
- case contacts.FieldRemarkName:
- return m.RemarkName()
- case contacts.FieldRemarkAvatar:
- return m.RemarkAvatar()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ContactsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case contacts.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case contacts.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case contacts.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case contacts.FieldChildID:
- return m.OldChildID(ctx)
- case contacts.FieldRefID:
- return m.OldRefID(ctx)
- case contacts.FieldRefType:
- return m.OldRefType(ctx)
- case contacts.FieldRemarkName:
- return m.OldRemarkName(ctx)
- case contacts.FieldRemarkAvatar:
- return m.OldRemarkAvatar(ctx)
- }
- return nil, fmt.Errorf("unknown Contacts field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ContactsMutation) SetField(name string, value ent.Value) error {
- switch name {
- case contacts.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case contacts.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case contacts.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case contacts.FieldChildID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChildID(v)
- return nil
- case contacts.FieldRefID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefID(v)
- return nil
- case contacts.FieldRefType:
- v, ok := value.(contacts.RefType)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefType(v)
- return nil
- case contacts.FieldRemarkName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRemarkName(v)
- return nil
- case contacts.FieldRemarkAvatar:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRemarkAvatar(v)
- return nil
- }
- return fmt.Errorf("unknown Contacts field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ContactsMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ContactsMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ContactsMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown Contacts numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ContactsMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(contacts.FieldDeletedAt) {
- fields = append(fields, contacts.FieldDeletedAt)
- }
- if m.FieldCleared(contacts.FieldChildID) {
- fields = append(fields, contacts.FieldChildID)
- }
- if m.FieldCleared(contacts.FieldRemarkName) {
- fields = append(fields, contacts.FieldRemarkName)
- }
- if m.FieldCleared(contacts.FieldRemarkAvatar) {
- fields = append(fields, contacts.FieldRemarkAvatar)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ContactsMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ContactsMutation) ClearField(name string) error {
- switch name {
- case contacts.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case contacts.FieldChildID:
- m.ClearChildID()
- return nil
- case contacts.FieldRemarkName:
- m.ClearRemarkName()
- return nil
- case contacts.FieldRemarkAvatar:
- m.ClearRemarkAvatar()
- return nil
- }
- return fmt.Errorf("unknown Contacts nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ContactsMutation) ResetField(name string) error {
- switch name {
- case contacts.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case contacts.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case contacts.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case contacts.FieldChildID:
- m.ResetChildID()
- return nil
- case contacts.FieldRefID:
- m.ResetRefID()
- return nil
- case contacts.FieldRefType:
- m.ResetRefType()
- return nil
- case contacts.FieldRemarkName:
- m.ResetRemarkName()
- return nil
- case contacts.FieldRemarkAvatar:
- m.ResetRemarkAvatar()
- return nil
- }
- return fmt.Errorf("unknown Contacts field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ContactsMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.child != nil {
- edges = append(edges, contacts.EdgeChild)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ContactsMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case contacts.EdgeChild:
- if id := m.child; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ContactsMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ContactsMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ContactsMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedchild {
- edges = append(edges, contacts.EdgeChild)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ContactsMutation) EdgeCleared(name string) bool {
- switch name {
- case contacts.EdgeChild:
- return m.clearedchild
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ContactsMutation) ClearEdge(name string) error {
- switch name {
- case contacts.EdgeChild:
- m.ClearChild()
- return nil
- }
- return fmt.Errorf("unknown Contacts unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ContactsMutation) ResetEdge(name string) error {
- switch name {
- case contacts.EdgeChild:
- m.ResetChild()
- return nil
- }
- return fmt.Errorf("unknown Contacts edge %s", name)
- }
- // DeviceMutation represents an operation that mutates the Device nodes in the graph.
- type DeviceMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- imei *string
- model *string
- ticket *string
- hc *string
- aes_key *string
- activation_time *time.Time
- clearedFields map[string]struct{}
- bind *int64
- clearedbind bool
- configs map[int64]struct{}
- removedconfigs map[int64]struct{}
- clearedconfigs bool
- done bool
- oldValue func(context.Context) (*Device, error)
- predicates []predicate.Device
- }
- var _ ent.Mutation = (*DeviceMutation)(nil)
- // deviceOption allows management of the mutation configuration using functional options.
- type deviceOption func(*DeviceMutation)
- // newDeviceMutation creates new mutation for the Device entity.
- func newDeviceMutation(c config, op Op, opts ...deviceOption) *DeviceMutation {
- m := &DeviceMutation{
- config: c,
- op: op,
- typ: TypeDevice,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withDeviceID sets the ID field of the mutation.
- func withDeviceID(id int64) deviceOption {
- return func(m *DeviceMutation) {
- var (
- err error
- once sync.Once
- value *Device
- )
- m.oldValue = func(ctx context.Context) (*Device, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Device.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withDevice sets the old Device of the mutation.
- func withDevice(node *Device) deviceOption {
- return func(m *DeviceMutation) {
- m.oldValue = func(context.Context) (*Device, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m DeviceMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m DeviceMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of Device entities.
- func (m *DeviceMutation) SetID(id int64) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *DeviceMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *DeviceMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Device.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *DeviceMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *DeviceMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *DeviceMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *DeviceMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *DeviceMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *DeviceMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *DeviceMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *DeviceMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *DeviceMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[device.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *DeviceMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[device.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *DeviceMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, device.FieldDeletedAt)
- }
- // SetImei sets the "imei" field.
- func (m *DeviceMutation) SetImei(s string) {
- m.imei = &s
- }
- // Imei returns the value of the "imei" field in the mutation.
- func (m *DeviceMutation) Imei() (r string, exists bool) {
- v := m.imei
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImei returns the old "imei" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldImei(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImei is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImei requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImei: %w", err)
- }
- return oldValue.Imei, nil
- }
- // ResetImei resets all changes to the "imei" field.
- func (m *DeviceMutation) ResetImei() {
- m.imei = nil
- }
- // SetModel sets the "model" field.
- func (m *DeviceMutation) SetModel(s string) {
- m.model = &s
- }
- // Model returns the value of the "model" field in the mutation.
- func (m *DeviceMutation) Model() (r string, exists bool) {
- v := m.model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModel returns the old "model" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModel: %w", err)
- }
- return oldValue.Model, nil
- }
- // ResetModel resets all changes to the "model" field.
- func (m *DeviceMutation) ResetModel() {
- m.model = nil
- }
- // SetTicket sets the "ticket" field.
- func (m *DeviceMutation) SetTicket(s string) {
- m.ticket = &s
- }
- // Ticket returns the value of the "ticket" field in the mutation.
- func (m *DeviceMutation) Ticket() (r string, exists bool) {
- v := m.ticket
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTicket returns the old "ticket" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldTicket(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTicket is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTicket requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTicket: %w", err)
- }
- return oldValue.Ticket, nil
- }
- // ResetTicket resets all changes to the "ticket" field.
- func (m *DeviceMutation) ResetTicket() {
- m.ticket = nil
- }
- // SetHc sets the "hc" field.
- func (m *DeviceMutation) SetHc(s string) {
- m.hc = &s
- }
- // Hc returns the value of the "hc" field in the mutation.
- func (m *DeviceMutation) Hc() (r string, exists bool) {
- v := m.hc
- if v == nil {
- return
- }
- return *v, true
- }
- // OldHc returns the old "hc" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldHc(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldHc is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldHc requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldHc: %w", err)
- }
- return oldValue.Hc, nil
- }
- // ResetHc resets all changes to the "hc" field.
- func (m *DeviceMutation) ResetHc() {
- m.hc = nil
- }
- // SetAesKey sets the "aes_key" field.
- func (m *DeviceMutation) SetAesKey(s string) {
- m.aes_key = &s
- }
- // AesKey returns the value of the "aes_key" field in the mutation.
- func (m *DeviceMutation) AesKey() (r string, exists bool) {
- v := m.aes_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAesKey returns the old "aes_key" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldAesKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAesKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAesKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAesKey: %w", err)
- }
- return oldValue.AesKey, nil
- }
- // ResetAesKey resets all changes to the "aes_key" field.
- func (m *DeviceMutation) ResetAesKey() {
- m.aes_key = nil
- }
- // SetActivationTime sets the "activation_time" field.
- func (m *DeviceMutation) SetActivationTime(t time.Time) {
- m.activation_time = &t
- }
- // ActivationTime returns the value of the "activation_time" field in the mutation.
- func (m *DeviceMutation) ActivationTime() (r time.Time, exists bool) {
- v := m.activation_time
- if v == nil {
- return
- }
- return *v, true
- }
- // OldActivationTime returns the old "activation_time" field's value of the Device entity.
- // If the Device object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceMutation) OldActivationTime(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldActivationTime is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldActivationTime requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldActivationTime: %w", err)
- }
- return oldValue.ActivationTime, nil
- }
- // ClearActivationTime clears the value of the "activation_time" field.
- func (m *DeviceMutation) ClearActivationTime() {
- m.activation_time = nil
- m.clearedFields[device.FieldActivationTime] = struct{}{}
- }
- // ActivationTimeCleared returns if the "activation_time" field was cleared in this mutation.
- func (m *DeviceMutation) ActivationTimeCleared() bool {
- _, ok := m.clearedFields[device.FieldActivationTime]
- return ok
- }
- // ResetActivationTime resets all changes to the "activation_time" field.
- func (m *DeviceMutation) ResetActivationTime() {
- m.activation_time = nil
- delete(m.clearedFields, device.FieldActivationTime)
- }
- // SetBindID sets the "bind" edge to the DeviceBind entity by id.
- func (m *DeviceMutation) SetBindID(id int64) {
- m.bind = &id
- }
- // ClearBind clears the "bind" edge to the DeviceBind entity.
- func (m *DeviceMutation) ClearBind() {
- m.clearedbind = true
- }
- // BindCleared reports if the "bind" edge to the DeviceBind entity was cleared.
- func (m *DeviceMutation) BindCleared() bool {
- return m.clearedbind
- }
- // BindID returns the "bind" edge ID in the mutation.
- func (m *DeviceMutation) BindID() (id int64, exists bool) {
- if m.bind != nil {
- return *m.bind, true
- }
- return
- }
- // BindIDs returns the "bind" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // BindID instead. It exists only for internal usage by the builders.
- func (m *DeviceMutation) BindIDs() (ids []int64) {
- if id := m.bind; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetBind resets all changes to the "bind" edge.
- func (m *DeviceMutation) ResetBind() {
- m.bind = nil
- m.clearedbind = false
- }
- // AddConfigIDs adds the "configs" edge to the DeviceConfig entity by ids.
- func (m *DeviceMutation) AddConfigIDs(ids ...int64) {
- if m.configs == nil {
- m.configs = make(map[int64]struct{})
- }
- for i := range ids {
- m.configs[ids[i]] = struct{}{}
- }
- }
- // ClearConfigs clears the "configs" edge to the DeviceConfig entity.
- func (m *DeviceMutation) ClearConfigs() {
- m.clearedconfigs = true
- }
- // ConfigsCleared reports if the "configs" edge to the DeviceConfig entity was cleared.
- func (m *DeviceMutation) ConfigsCleared() bool {
- return m.clearedconfigs
- }
- // RemoveConfigIDs removes the "configs" edge to the DeviceConfig entity by IDs.
- func (m *DeviceMutation) RemoveConfigIDs(ids ...int64) {
- if m.removedconfigs == nil {
- m.removedconfigs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.configs, ids[i])
- m.removedconfigs[ids[i]] = struct{}{}
- }
- }
- // RemovedConfigs returns the removed IDs of the "configs" edge to the DeviceConfig entity.
- func (m *DeviceMutation) RemovedConfigsIDs() (ids []int64) {
- for id := range m.removedconfigs {
- ids = append(ids, id)
- }
- return
- }
- // ConfigsIDs returns the "configs" edge IDs in the mutation.
- func (m *DeviceMutation) ConfigsIDs() (ids []int64) {
- for id := range m.configs {
- ids = append(ids, id)
- }
- return
- }
- // ResetConfigs resets all changes to the "configs" edge.
- func (m *DeviceMutation) ResetConfigs() {
- m.configs = nil
- m.clearedconfigs = false
- m.removedconfigs = nil
- }
- // Where appends a list predicates to the DeviceMutation builder.
- func (m *DeviceMutation) Where(ps ...predicate.Device) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the DeviceMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *DeviceMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Device, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *DeviceMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *DeviceMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Device).
- func (m *DeviceMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *DeviceMutation) Fields() []string {
- fields := make([]string, 0, 9)
- if m.created_at != nil {
- fields = append(fields, device.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, device.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, device.FieldDeletedAt)
- }
- if m.imei != nil {
- fields = append(fields, device.FieldImei)
- }
- if m.model != nil {
- fields = append(fields, device.FieldModel)
- }
- if m.ticket != nil {
- fields = append(fields, device.FieldTicket)
- }
- if m.hc != nil {
- fields = append(fields, device.FieldHc)
- }
- if m.aes_key != nil {
- fields = append(fields, device.FieldAesKey)
- }
- if m.activation_time != nil {
- fields = append(fields, device.FieldActivationTime)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *DeviceMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case device.FieldCreatedAt:
- return m.CreatedAt()
- case device.FieldUpdatedAt:
- return m.UpdatedAt()
- case device.FieldDeletedAt:
- return m.DeletedAt()
- case device.FieldImei:
- return m.Imei()
- case device.FieldModel:
- return m.Model()
- case device.FieldTicket:
- return m.Ticket()
- case device.FieldHc:
- return m.Hc()
- case device.FieldAesKey:
- return m.AesKey()
- case device.FieldActivationTime:
- return m.ActivationTime()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *DeviceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case device.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case device.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case device.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case device.FieldImei:
- return m.OldImei(ctx)
- case device.FieldModel:
- return m.OldModel(ctx)
- case device.FieldTicket:
- return m.OldTicket(ctx)
- case device.FieldHc:
- return m.OldHc(ctx)
- case device.FieldAesKey:
- return m.OldAesKey(ctx)
- case device.FieldActivationTime:
- return m.OldActivationTime(ctx)
- }
- return nil, fmt.Errorf("unknown Device field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceMutation) SetField(name string, value ent.Value) error {
- switch name {
- case device.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case device.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case device.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case device.FieldImei:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImei(v)
- return nil
- case device.FieldModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModel(v)
- return nil
- case device.FieldTicket:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTicket(v)
- return nil
- case device.FieldHc:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetHc(v)
- return nil
- case device.FieldAesKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAesKey(v)
- return nil
- case device.FieldActivationTime:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetActivationTime(v)
- return nil
- }
- return fmt.Errorf("unknown Device field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *DeviceMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *DeviceMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown Device numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *DeviceMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(device.FieldDeletedAt) {
- fields = append(fields, device.FieldDeletedAt)
- }
- if m.FieldCleared(device.FieldActivationTime) {
- fields = append(fields, device.FieldActivationTime)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *DeviceMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *DeviceMutation) ClearField(name string) error {
- switch name {
- case device.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case device.FieldActivationTime:
- m.ClearActivationTime()
- return nil
- }
- return fmt.Errorf("unknown Device nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *DeviceMutation) ResetField(name string) error {
- switch name {
- case device.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case device.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case device.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case device.FieldImei:
- m.ResetImei()
- return nil
- case device.FieldModel:
- m.ResetModel()
- return nil
- case device.FieldTicket:
- m.ResetTicket()
- return nil
- case device.FieldHc:
- m.ResetHc()
- return nil
- case device.FieldAesKey:
- m.ResetAesKey()
- return nil
- case device.FieldActivationTime:
- m.ResetActivationTime()
- return nil
- }
- return fmt.Errorf("unknown Device field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *DeviceMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.bind != nil {
- edges = append(edges, device.EdgeBind)
- }
- if m.configs != nil {
- edges = append(edges, device.EdgeConfigs)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *DeviceMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case device.EdgeBind:
- if id := m.bind; id != nil {
- return []ent.Value{*id}
- }
- case device.EdgeConfigs:
- ids := make([]ent.Value, 0, len(m.configs))
- for id := range m.configs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *DeviceMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- if m.removedconfigs != nil {
- edges = append(edges, device.EdgeConfigs)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *DeviceMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case device.EdgeConfigs:
- ids := make([]ent.Value, 0, len(m.removedconfigs))
- for id := range m.removedconfigs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *DeviceMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedbind {
- edges = append(edges, device.EdgeBind)
- }
- if m.clearedconfigs {
- edges = append(edges, device.EdgeConfigs)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *DeviceMutation) EdgeCleared(name string) bool {
- switch name {
- case device.EdgeBind:
- return m.clearedbind
- case device.EdgeConfigs:
- return m.clearedconfigs
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *DeviceMutation) ClearEdge(name string) error {
- switch name {
- case device.EdgeBind:
- m.ClearBind()
- return nil
- }
- return fmt.Errorf("unknown Device unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *DeviceMutation) ResetEdge(name string) error {
- switch name {
- case device.EdgeBind:
- m.ResetBind()
- return nil
- case device.EdgeConfigs:
- m.ResetConfigs()
- return nil
- }
- return fmt.Errorf("unknown Device edge %s", name)
- }
- // DeviceBindMutation represents an operation that mutates the DeviceBind nodes in the graph.
- type DeviceBindMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- clearedFields map[string]struct{}
- device *int64
- cleareddevice bool
- child *uuid.UUID
- clearedchild bool
- done bool
- oldValue func(context.Context) (*DeviceBind, error)
- predicates []predicate.DeviceBind
- }
- var _ ent.Mutation = (*DeviceBindMutation)(nil)
- // devicebindOption allows management of the mutation configuration using functional options.
- type devicebindOption func(*DeviceBindMutation)
- // newDeviceBindMutation creates new mutation for the DeviceBind entity.
- func newDeviceBindMutation(c config, op Op, opts ...devicebindOption) *DeviceBindMutation {
- m := &DeviceBindMutation{
- config: c,
- op: op,
- typ: TypeDeviceBind,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withDeviceBindID sets the ID field of the mutation.
- func withDeviceBindID(id int64) devicebindOption {
- return func(m *DeviceBindMutation) {
- var (
- err error
- once sync.Once
- value *DeviceBind
- )
- m.oldValue = func(ctx context.Context) (*DeviceBind, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().DeviceBind.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withDeviceBind sets the old DeviceBind of the mutation.
- func withDeviceBind(node *DeviceBind) devicebindOption {
- return func(m *DeviceBindMutation) {
- m.oldValue = func(context.Context) (*DeviceBind, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m DeviceBindMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m DeviceBindMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of DeviceBind entities.
- func (m *DeviceBindMutation) SetID(id int64) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *DeviceBindMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *DeviceBindMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().DeviceBind.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *DeviceBindMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *DeviceBindMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the DeviceBind entity.
- // If the DeviceBind object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceBindMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *DeviceBindMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *DeviceBindMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *DeviceBindMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the DeviceBind entity.
- // If the DeviceBind object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceBindMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *DeviceBindMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *DeviceBindMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *DeviceBindMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the DeviceBind entity.
- // If the DeviceBind object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceBindMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *DeviceBindMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[devicebind.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *DeviceBindMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[devicebind.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *DeviceBindMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, devicebind.FieldDeletedAt)
- }
- // SetDeviceID sets the "device_id" field.
- func (m *DeviceBindMutation) SetDeviceID(i int64) {
- m.device = &i
- }
- // DeviceID returns the value of the "device_id" field in the mutation.
- func (m *DeviceBindMutation) DeviceID() (r int64, exists bool) {
- v := m.device
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeviceID returns the old "device_id" field's value of the DeviceBind entity.
- // If the DeviceBind object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceBindMutation) OldDeviceID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeviceID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeviceID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeviceID: %w", err)
- }
- return oldValue.DeviceID, nil
- }
- // ClearDeviceID clears the value of the "device_id" field.
- func (m *DeviceBindMutation) ClearDeviceID() {
- m.device = nil
- m.clearedFields[devicebind.FieldDeviceID] = struct{}{}
- }
- // DeviceIDCleared returns if the "device_id" field was cleared in this mutation.
- func (m *DeviceBindMutation) DeviceIDCleared() bool {
- _, ok := m.clearedFields[devicebind.FieldDeviceID]
- return ok
- }
- // ResetDeviceID resets all changes to the "device_id" field.
- func (m *DeviceBindMutation) ResetDeviceID() {
- m.device = nil
- delete(m.clearedFields, devicebind.FieldDeviceID)
- }
- // SetChildID sets the "child_id" field.
- func (m *DeviceBindMutation) SetChildID(u uuid.UUID) {
- m.child = &u
- }
- // ChildID returns the value of the "child_id" field in the mutation.
- func (m *DeviceBindMutation) ChildID() (r uuid.UUID, exists bool) {
- v := m.child
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChildID returns the old "child_id" field's value of the DeviceBind entity.
- // If the DeviceBind object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceBindMutation) OldChildID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChildID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChildID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChildID: %w", err)
- }
- return oldValue.ChildID, nil
- }
- // ClearChildID clears the value of the "child_id" field.
- func (m *DeviceBindMutation) ClearChildID() {
- m.child = nil
- m.clearedFields[devicebind.FieldChildID] = struct{}{}
- }
- // ChildIDCleared returns if the "child_id" field was cleared in this mutation.
- func (m *DeviceBindMutation) ChildIDCleared() bool {
- _, ok := m.clearedFields[devicebind.FieldChildID]
- return ok
- }
- // ResetChildID resets all changes to the "child_id" field.
- func (m *DeviceBindMutation) ResetChildID() {
- m.child = nil
- delete(m.clearedFields, devicebind.FieldChildID)
- }
- // ClearDevice clears the "device" edge to the Device entity.
- func (m *DeviceBindMutation) ClearDevice() {
- m.cleareddevice = true
- m.clearedFields[devicebind.FieldDeviceID] = struct{}{}
- }
- // DeviceCleared reports if the "device" edge to the Device entity was cleared.
- func (m *DeviceBindMutation) DeviceCleared() bool {
- return m.DeviceIDCleared() || m.cleareddevice
- }
- // DeviceIDs returns the "device" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // DeviceID instead. It exists only for internal usage by the builders.
- func (m *DeviceBindMutation) DeviceIDs() (ids []int64) {
- if id := m.device; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetDevice resets all changes to the "device" edge.
- func (m *DeviceBindMutation) ResetDevice() {
- m.device = nil
- m.cleareddevice = false
- }
- // ClearChild clears the "child" edge to the Child entity.
- func (m *DeviceBindMutation) ClearChild() {
- m.clearedchild = true
- m.clearedFields[devicebind.FieldChildID] = struct{}{}
- }
- // ChildCleared reports if the "child" edge to the Child entity was cleared.
- func (m *DeviceBindMutation) ChildCleared() bool {
- return m.ChildIDCleared() || m.clearedchild
- }
- // ChildIDs returns the "child" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // ChildID instead. It exists only for internal usage by the builders.
- func (m *DeviceBindMutation) ChildIDs() (ids []uuid.UUID) {
- if id := m.child; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetChild resets all changes to the "child" edge.
- func (m *DeviceBindMutation) ResetChild() {
- m.child = nil
- m.clearedchild = false
- }
- // Where appends a list predicates to the DeviceBindMutation builder.
- func (m *DeviceBindMutation) Where(ps ...predicate.DeviceBind) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the DeviceBindMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *DeviceBindMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.DeviceBind, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *DeviceBindMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *DeviceBindMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (DeviceBind).
- func (m *DeviceBindMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *DeviceBindMutation) Fields() []string {
- fields := make([]string, 0, 5)
- if m.created_at != nil {
- fields = append(fields, devicebind.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, devicebind.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, devicebind.FieldDeletedAt)
- }
- if m.device != nil {
- fields = append(fields, devicebind.FieldDeviceID)
- }
- if m.child != nil {
- fields = append(fields, devicebind.FieldChildID)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *DeviceBindMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case devicebind.FieldCreatedAt:
- return m.CreatedAt()
- case devicebind.FieldUpdatedAt:
- return m.UpdatedAt()
- case devicebind.FieldDeletedAt:
- return m.DeletedAt()
- case devicebind.FieldDeviceID:
- return m.DeviceID()
- case devicebind.FieldChildID:
- return m.ChildID()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *DeviceBindMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case devicebind.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case devicebind.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case devicebind.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case devicebind.FieldDeviceID:
- return m.OldDeviceID(ctx)
- case devicebind.FieldChildID:
- return m.OldChildID(ctx)
- }
- return nil, fmt.Errorf("unknown DeviceBind field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceBindMutation) SetField(name string, value ent.Value) error {
- switch name {
- case devicebind.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case devicebind.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case devicebind.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case devicebind.FieldDeviceID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeviceID(v)
- return nil
- case devicebind.FieldChildID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChildID(v)
- return nil
- }
- return fmt.Errorf("unknown DeviceBind field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *DeviceBindMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *DeviceBindMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceBindMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown DeviceBind numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *DeviceBindMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(devicebind.FieldDeletedAt) {
- fields = append(fields, devicebind.FieldDeletedAt)
- }
- if m.FieldCleared(devicebind.FieldDeviceID) {
- fields = append(fields, devicebind.FieldDeviceID)
- }
- if m.FieldCleared(devicebind.FieldChildID) {
- fields = append(fields, devicebind.FieldChildID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *DeviceBindMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *DeviceBindMutation) ClearField(name string) error {
- switch name {
- case devicebind.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case devicebind.FieldDeviceID:
- m.ClearDeviceID()
- return nil
- case devicebind.FieldChildID:
- m.ClearChildID()
- return nil
- }
- return fmt.Errorf("unknown DeviceBind nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *DeviceBindMutation) ResetField(name string) error {
- switch name {
- case devicebind.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case devicebind.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case devicebind.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case devicebind.FieldDeviceID:
- m.ResetDeviceID()
- return nil
- case devicebind.FieldChildID:
- m.ResetChildID()
- return nil
- }
- return fmt.Errorf("unknown DeviceBind field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *DeviceBindMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.device != nil {
- edges = append(edges, devicebind.EdgeDevice)
- }
- if m.child != nil {
- edges = append(edges, devicebind.EdgeChild)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *DeviceBindMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case devicebind.EdgeDevice:
- if id := m.device; id != nil {
- return []ent.Value{*id}
- }
- case devicebind.EdgeChild:
- if id := m.child; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *DeviceBindMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *DeviceBindMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *DeviceBindMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.cleareddevice {
- edges = append(edges, devicebind.EdgeDevice)
- }
- if m.clearedchild {
- edges = append(edges, devicebind.EdgeChild)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *DeviceBindMutation) EdgeCleared(name string) bool {
- switch name {
- case devicebind.EdgeDevice:
- return m.cleareddevice
- case devicebind.EdgeChild:
- return m.clearedchild
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *DeviceBindMutation) ClearEdge(name string) error {
- switch name {
- case devicebind.EdgeDevice:
- m.ClearDevice()
- return nil
- case devicebind.EdgeChild:
- m.ClearChild()
- return nil
- }
- return fmt.Errorf("unknown DeviceBind unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *DeviceBindMutation) ResetEdge(name string) error {
- switch name {
- case devicebind.EdgeDevice:
- m.ResetDevice()
- return nil
- case devicebind.EdgeChild:
- m.ResetChild()
- return nil
- }
- return fmt.Errorf("unknown DeviceBind edge %s", name)
- }
- // DeviceConfigMutation represents an operation that mutates the DeviceConfig nodes in the graph.
- type DeviceConfigMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- key *string
- value *string
- before_value *string
- clearedFields map[string]struct{}
- device *int64
- cleareddevice bool
- done bool
- oldValue func(context.Context) (*DeviceConfig, error)
- predicates []predicate.DeviceConfig
- }
- var _ ent.Mutation = (*DeviceConfigMutation)(nil)
- // deviceconfigOption allows management of the mutation configuration using functional options.
- type deviceconfigOption func(*DeviceConfigMutation)
- // newDeviceConfigMutation creates new mutation for the DeviceConfig entity.
- func newDeviceConfigMutation(c config, op Op, opts ...deviceconfigOption) *DeviceConfigMutation {
- m := &DeviceConfigMutation{
- config: c,
- op: op,
- typ: TypeDeviceConfig,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withDeviceConfigID sets the ID field of the mutation.
- func withDeviceConfigID(id int64) deviceconfigOption {
- return func(m *DeviceConfigMutation) {
- var (
- err error
- once sync.Once
- value *DeviceConfig
- )
- m.oldValue = func(ctx context.Context) (*DeviceConfig, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().DeviceConfig.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withDeviceConfig sets the old DeviceConfig of the mutation.
- func withDeviceConfig(node *DeviceConfig) deviceconfigOption {
- return func(m *DeviceConfigMutation) {
- m.oldValue = func(context.Context) (*DeviceConfig, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m DeviceConfigMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m DeviceConfigMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of DeviceConfig entities.
- func (m *DeviceConfigMutation) SetID(id int64) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *DeviceConfigMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *DeviceConfigMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().DeviceConfig.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *DeviceConfigMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *DeviceConfigMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *DeviceConfigMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *DeviceConfigMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *DeviceConfigMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *DeviceConfigMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *DeviceConfigMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *DeviceConfigMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *DeviceConfigMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[deviceconfig.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *DeviceConfigMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[deviceconfig.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *DeviceConfigMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, deviceconfig.FieldDeletedAt)
- }
- // SetDeviceID sets the "device_id" field.
- func (m *DeviceConfigMutation) SetDeviceID(i int64) {
- m.device = &i
- }
- // DeviceID returns the value of the "device_id" field in the mutation.
- func (m *DeviceConfigMutation) DeviceID() (r int64, exists bool) {
- v := m.device
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeviceID returns the old "device_id" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldDeviceID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeviceID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeviceID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeviceID: %w", err)
- }
- return oldValue.DeviceID, nil
- }
- // ClearDeviceID clears the value of the "device_id" field.
- func (m *DeviceConfigMutation) ClearDeviceID() {
- m.device = nil
- m.clearedFields[deviceconfig.FieldDeviceID] = struct{}{}
- }
- // DeviceIDCleared returns if the "device_id" field was cleared in this mutation.
- func (m *DeviceConfigMutation) DeviceIDCleared() bool {
- _, ok := m.clearedFields[deviceconfig.FieldDeviceID]
- return ok
- }
- // ResetDeviceID resets all changes to the "device_id" field.
- func (m *DeviceConfigMutation) ResetDeviceID() {
- m.device = nil
- delete(m.clearedFields, deviceconfig.FieldDeviceID)
- }
- // SetKey sets the "key" field.
- func (m *DeviceConfigMutation) SetKey(s string) {
- m.key = &s
- }
- // Key returns the value of the "key" field in the mutation.
- func (m *DeviceConfigMutation) Key() (r string, exists bool) {
- v := m.key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKey returns the old "key" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKey: %w", err)
- }
- return oldValue.Key, nil
- }
- // ResetKey resets all changes to the "key" field.
- func (m *DeviceConfigMutation) ResetKey() {
- m.key = nil
- }
- // SetValue sets the "value" field.
- func (m *DeviceConfigMutation) SetValue(s string) {
- m.value = &s
- }
- // Value returns the value of the "value" field in the mutation.
- func (m *DeviceConfigMutation) Value() (r string, exists bool) {
- v := m.value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValue returns the old "value" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldValue(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValue: %w", err)
- }
- return oldValue.Value, nil
- }
- // ResetValue resets all changes to the "value" field.
- func (m *DeviceConfigMutation) ResetValue() {
- m.value = nil
- }
- // SetBeforeValue sets the "before_value" field.
- func (m *DeviceConfigMutation) SetBeforeValue(s string) {
- m.before_value = &s
- }
- // BeforeValue returns the value of the "before_value" field in the mutation.
- func (m *DeviceConfigMutation) BeforeValue() (r string, exists bool) {
- v := m.before_value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBeforeValue returns the old "before_value" field's value of the DeviceConfig entity.
- // If the DeviceConfig object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *DeviceConfigMutation) OldBeforeValue(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBeforeValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBeforeValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBeforeValue: %w", err)
- }
- return oldValue.BeforeValue, nil
- }
- // ClearBeforeValue clears the value of the "before_value" field.
- func (m *DeviceConfigMutation) ClearBeforeValue() {
- m.before_value = nil
- m.clearedFields[deviceconfig.FieldBeforeValue] = struct{}{}
- }
- // BeforeValueCleared returns if the "before_value" field was cleared in this mutation.
- func (m *DeviceConfigMutation) BeforeValueCleared() bool {
- _, ok := m.clearedFields[deviceconfig.FieldBeforeValue]
- return ok
- }
- // ResetBeforeValue resets all changes to the "before_value" field.
- func (m *DeviceConfigMutation) ResetBeforeValue() {
- m.before_value = nil
- delete(m.clearedFields, deviceconfig.FieldBeforeValue)
- }
- // ClearDevice clears the "device" edge to the Device entity.
- func (m *DeviceConfigMutation) ClearDevice() {
- m.cleareddevice = true
- m.clearedFields[deviceconfig.FieldDeviceID] = struct{}{}
- }
- // DeviceCleared reports if the "device" edge to the Device entity was cleared.
- func (m *DeviceConfigMutation) DeviceCleared() bool {
- return m.DeviceIDCleared() || m.cleareddevice
- }
- // DeviceIDs returns the "device" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // DeviceID instead. It exists only for internal usage by the builders.
- func (m *DeviceConfigMutation) DeviceIDs() (ids []int64) {
- if id := m.device; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetDevice resets all changes to the "device" edge.
- func (m *DeviceConfigMutation) ResetDevice() {
- m.device = nil
- m.cleareddevice = false
- }
- // Where appends a list predicates to the DeviceConfigMutation builder.
- func (m *DeviceConfigMutation) Where(ps ...predicate.DeviceConfig) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the DeviceConfigMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *DeviceConfigMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.DeviceConfig, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *DeviceConfigMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *DeviceConfigMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (DeviceConfig).
- func (m *DeviceConfigMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *DeviceConfigMutation) Fields() []string {
- fields := make([]string, 0, 7)
- if m.created_at != nil {
- fields = append(fields, deviceconfig.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, deviceconfig.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, deviceconfig.FieldDeletedAt)
- }
- if m.device != nil {
- fields = append(fields, deviceconfig.FieldDeviceID)
- }
- if m.key != nil {
- fields = append(fields, deviceconfig.FieldKey)
- }
- if m.value != nil {
- fields = append(fields, deviceconfig.FieldValue)
- }
- if m.before_value != nil {
- fields = append(fields, deviceconfig.FieldBeforeValue)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *DeviceConfigMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case deviceconfig.FieldCreatedAt:
- return m.CreatedAt()
- case deviceconfig.FieldUpdatedAt:
- return m.UpdatedAt()
- case deviceconfig.FieldDeletedAt:
- return m.DeletedAt()
- case deviceconfig.FieldDeviceID:
- return m.DeviceID()
- case deviceconfig.FieldKey:
- return m.Key()
- case deviceconfig.FieldValue:
- return m.Value()
- case deviceconfig.FieldBeforeValue:
- return m.BeforeValue()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *DeviceConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case deviceconfig.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case deviceconfig.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case deviceconfig.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case deviceconfig.FieldDeviceID:
- return m.OldDeviceID(ctx)
- case deviceconfig.FieldKey:
- return m.OldKey(ctx)
- case deviceconfig.FieldValue:
- return m.OldValue(ctx)
- case deviceconfig.FieldBeforeValue:
- return m.OldBeforeValue(ctx)
- }
- return nil, fmt.Errorf("unknown DeviceConfig field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceConfigMutation) SetField(name string, value ent.Value) error {
- switch name {
- case deviceconfig.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case deviceconfig.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case deviceconfig.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case deviceconfig.FieldDeviceID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeviceID(v)
- return nil
- case deviceconfig.FieldKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKey(v)
- return nil
- case deviceconfig.FieldValue:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValue(v)
- return nil
- case deviceconfig.FieldBeforeValue:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBeforeValue(v)
- return nil
- }
- return fmt.Errorf("unknown DeviceConfig field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *DeviceConfigMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *DeviceConfigMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *DeviceConfigMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown DeviceConfig numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *DeviceConfigMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(deviceconfig.FieldDeletedAt) {
- fields = append(fields, deviceconfig.FieldDeletedAt)
- }
- if m.FieldCleared(deviceconfig.FieldDeviceID) {
- fields = append(fields, deviceconfig.FieldDeviceID)
- }
- if m.FieldCleared(deviceconfig.FieldBeforeValue) {
- fields = append(fields, deviceconfig.FieldBeforeValue)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *DeviceConfigMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *DeviceConfigMutation) ClearField(name string) error {
- switch name {
- case deviceconfig.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case deviceconfig.FieldDeviceID:
- m.ClearDeviceID()
- return nil
- case deviceconfig.FieldBeforeValue:
- m.ClearBeforeValue()
- return nil
- }
- return fmt.Errorf("unknown DeviceConfig nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *DeviceConfigMutation) ResetField(name string) error {
- switch name {
- case deviceconfig.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case deviceconfig.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case deviceconfig.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case deviceconfig.FieldDeviceID:
- m.ResetDeviceID()
- return nil
- case deviceconfig.FieldKey:
- m.ResetKey()
- return nil
- case deviceconfig.FieldValue:
- m.ResetValue()
- return nil
- case deviceconfig.FieldBeforeValue:
- m.ResetBeforeValue()
- return nil
- }
- return fmt.Errorf("unknown DeviceConfig field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *DeviceConfigMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.device != nil {
- edges = append(edges, deviceconfig.EdgeDevice)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *DeviceConfigMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case deviceconfig.EdgeDevice:
- if id := m.device; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *DeviceConfigMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *DeviceConfigMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *DeviceConfigMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.cleareddevice {
- edges = append(edges, deviceconfig.EdgeDevice)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *DeviceConfigMutation) EdgeCleared(name string) bool {
- switch name {
- case deviceconfig.EdgeDevice:
- return m.cleareddevice
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *DeviceConfigMutation) ClearEdge(name string) error {
- switch name {
- case deviceconfig.EdgeDevice:
- m.ClearDevice()
- return nil
- }
- return fmt.Errorf("unknown DeviceConfig unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *DeviceConfigMutation) ResetEdge(name string) error {
- switch name {
- case deviceconfig.EdgeDevice:
- m.ResetDevice()
- return nil
- }
- return fmt.Errorf("unknown DeviceConfig edge %s", name)
- }
- // GroupMutation represents an operation that mutates the Group nodes in the graph.
- type GroupMutation struct {
- config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- child_id *uuid.UUID
- clearedFields map[string]struct{}
- members map[int64]struct{}
- removedmembers map[int64]struct{}
- clearedmembers bool
- done bool
- oldValue func(context.Context) (*Group, error)
- predicates []predicate.Group
- }
- var _ ent.Mutation = (*GroupMutation)(nil)
- // groupOption allows management of the mutation configuration using functional options.
- type groupOption func(*GroupMutation)
- // newGroupMutation creates new mutation for the Group entity.
- func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
- m := &GroupMutation{
- config: c,
- op: op,
- typ: TypeGroup,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withGroupID sets the ID field of the mutation.
- func withGroupID(id uuid.UUID) groupOption {
- return func(m *GroupMutation) {
- var (
- err error
- once sync.Once
- value *Group
- )
- m.oldValue = func(ctx context.Context) (*Group, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Group.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withGroup sets the old Group of the mutation.
- func withGroup(node *Group) groupOption {
- return func(m *GroupMutation) {
- m.oldValue = func(context.Context) (*Group, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m GroupMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m GroupMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of Group entities.
- func (m *GroupMutation) SetID(id uuid.UUID) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *GroupMutation) ID() (id uuid.UUID, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *GroupMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []uuid.UUID{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Group.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *GroupMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *GroupMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *GroupMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *GroupMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *GroupMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *GroupMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *GroupMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *GroupMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *GroupMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[group.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *GroupMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[group.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *GroupMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, group.FieldDeletedAt)
- }
- // SetChildID sets the "child_id" field.
- func (m *GroupMutation) SetChildID(u uuid.UUID) {
- m.child_id = &u
- }
- // ChildID returns the value of the "child_id" field in the mutation.
- func (m *GroupMutation) ChildID() (r uuid.UUID, exists bool) {
- v := m.child_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChildID returns the old "child_id" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldChildID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChildID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChildID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChildID: %w", err)
- }
- return oldValue.ChildID, nil
- }
- // ResetChildID resets all changes to the "child_id" field.
- func (m *GroupMutation) ResetChildID() {
- m.child_id = nil
- }
- // AddMemberIDs adds the "members" edge to the Member entity by ids.
- func (m *GroupMutation) AddMemberIDs(ids ...int64) {
- if m.members == nil {
- m.members = make(map[int64]struct{})
- }
- for i := range ids {
- m.members[ids[i]] = struct{}{}
- }
- }
- // ClearMembers clears the "members" edge to the Member entity.
- func (m *GroupMutation) ClearMembers() {
- m.clearedmembers = true
- }
- // MembersCleared reports if the "members" edge to the Member entity was cleared.
- func (m *GroupMutation) MembersCleared() bool {
- return m.clearedmembers
- }
- // RemoveMemberIDs removes the "members" edge to the Member entity by IDs.
- func (m *GroupMutation) RemoveMemberIDs(ids ...int64) {
- if m.removedmembers == nil {
- m.removedmembers = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.members, ids[i])
- m.removedmembers[ids[i]] = struct{}{}
- }
- }
- // RemovedMembers returns the removed IDs of the "members" edge to the Member entity.
- func (m *GroupMutation) RemovedMembersIDs() (ids []int64) {
- for id := range m.removedmembers {
- ids = append(ids, id)
- }
- return
- }
- // MembersIDs returns the "members" edge IDs in the mutation.
- func (m *GroupMutation) MembersIDs() (ids []int64) {
- for id := range m.members {
- ids = append(ids, id)
- }
- return
- }
- // ResetMembers resets all changes to the "members" edge.
- func (m *GroupMutation) ResetMembers() {
- m.members = nil
- m.clearedmembers = false
- m.removedmembers = nil
- }
- // Where appends a list predicates to the GroupMutation builder.
- func (m *GroupMutation) Where(ps ...predicate.Group) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the GroupMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *GroupMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Group, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *GroupMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *GroupMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Group).
- func (m *GroupMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *GroupMutation) Fields() []string {
- fields := make([]string, 0, 4)
- if m.created_at != nil {
- fields = append(fields, group.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, group.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, group.FieldDeletedAt)
- }
- if m.child_id != nil {
- fields = append(fields, group.FieldChildID)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *GroupMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case group.FieldCreatedAt:
- return m.CreatedAt()
- case group.FieldUpdatedAt:
- return m.UpdatedAt()
- case group.FieldDeletedAt:
- return m.DeletedAt()
- case group.FieldChildID:
- return m.ChildID()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case group.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case group.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case group.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case group.FieldChildID:
- return m.OldChildID(ctx)
- }
- return nil, fmt.Errorf("unknown Group field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *GroupMutation) SetField(name string, value ent.Value) error {
- switch name {
- case group.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case group.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case group.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case group.FieldChildID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChildID(v)
- return nil
- }
- return fmt.Errorf("unknown Group field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *GroupMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *GroupMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown Group numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *GroupMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(group.FieldDeletedAt) {
- fields = append(fields, group.FieldDeletedAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *GroupMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *GroupMutation) ClearField(name string) error {
- switch name {
- case group.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- }
- return fmt.Errorf("unknown Group nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *GroupMutation) ResetField(name string) error {
- switch name {
- case group.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case group.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case group.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case group.FieldChildID:
- m.ResetChildID()
- return nil
- }
- return fmt.Errorf("unknown Group field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *GroupMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.members != nil {
- edges = append(edges, group.EdgeMembers)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *GroupMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case group.EdgeMembers:
- ids := make([]ent.Value, 0, len(m.members))
- for id := range m.members {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *GroupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedmembers != nil {
- edges = append(edges, group.EdgeMembers)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case group.EdgeMembers:
- ids := make([]ent.Value, 0, len(m.removedmembers))
- for id := range m.removedmembers {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *GroupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedmembers {
- edges = append(edges, group.EdgeMembers)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *GroupMutation) EdgeCleared(name string) bool {
- switch name {
- case group.EdgeMembers:
- return m.clearedmembers
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *GroupMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown Group unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *GroupMutation) ResetEdge(name string) error {
- switch name {
- case group.EdgeMembers:
- m.ResetMembers()
- return nil
- }
- return fmt.Errorf("unknown Group edge %s", name)
- }
- // MemberMutation represents an operation that mutates the Member nodes in the graph.
- type MemberMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- ref_id *string
- _type *int8
- add_type *int8
- role *int8
- addrole *int8
- clearedFields map[string]struct{}
- group *uuid.UUID
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*Member, error)
- predicates []predicate.Member
- }
- var _ ent.Mutation = (*MemberMutation)(nil)
- // memberOption allows management of the mutation configuration using functional options.
- type memberOption func(*MemberMutation)
- // newMemberMutation creates new mutation for the Member entity.
- func newMemberMutation(c config, op Op, opts ...memberOption) *MemberMutation {
- m := &MemberMutation{
- config: c,
- op: op,
- typ: TypeMember,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withMemberID sets the ID field of the mutation.
- func withMemberID(id int64) memberOption {
- return func(m *MemberMutation) {
- var (
- err error
- once sync.Once
- value *Member
- )
- m.oldValue = func(ctx context.Context) (*Member, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Member.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withMember sets the old Member of the mutation.
- func withMember(node *Member) memberOption {
- return func(m *MemberMutation) {
- m.oldValue = func(context.Context) (*Member, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m MemberMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m MemberMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of Member entities.
- func (m *MemberMutation) SetID(id int64) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *MemberMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *MemberMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Member.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *MemberMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *MemberMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *MemberMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *MemberMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *MemberMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *MemberMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *MemberMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *MemberMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *MemberMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[member.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *MemberMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[member.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *MemberMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, member.FieldDeletedAt)
- }
- // SetGroupID sets the "group_id" field.
- func (m *MemberMutation) SetGroupID(u uuid.UUID) {
- m.group = &u
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *MemberMutation) GroupID() (r uuid.UUID, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (m *MemberMutation) ClearGroupID() {
- m.group = nil
- m.clearedFields[member.FieldGroupID] = struct{}{}
- }
- // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
- func (m *MemberMutation) GroupIDCleared() bool {
- _, ok := m.clearedFields[member.FieldGroupID]
- return ok
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *MemberMutation) ResetGroupID() {
- m.group = nil
- delete(m.clearedFields, member.FieldGroupID)
- }
- // SetRefID sets the "ref_id" field.
- func (m *MemberMutation) SetRefID(s string) {
- m.ref_id = &s
- }
- // RefID returns the value of the "ref_id" field in the mutation.
- func (m *MemberMutation) RefID() (r string, exists bool) {
- v := m.ref_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefID returns the old "ref_id" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldRefID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefID: %w", err)
- }
- return oldValue.RefID, nil
- }
- // ResetRefID resets all changes to the "ref_id" field.
- func (m *MemberMutation) ResetRefID() {
- m.ref_id = nil
- }
- // SetType sets the "type" field.
- func (m *MemberMutation) SetType(i int8) {
- m._type = &i
- m.add_type = nil
- }
- // GetType returns the value of the "type" field in the mutation.
- func (m *MemberMutation) GetType() (r int8, exists bool) {
- v := m._type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldType returns the old "type" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldType(ctx context.Context) (v int8, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldType: %w", err)
- }
- return oldValue.Type, nil
- }
- // AddType adds i to the "type" field.
- func (m *MemberMutation) AddType(i int8) {
- if m.add_type != nil {
- *m.add_type += i
- } else {
- m.add_type = &i
- }
- }
- // AddedType returns the value that was added to the "type" field in this mutation.
- func (m *MemberMutation) AddedType() (r int8, exists bool) {
- v := m.add_type
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetType resets all changes to the "type" field.
- func (m *MemberMutation) ResetType() {
- m._type = nil
- m.add_type = nil
- }
- // SetRole sets the "role" field.
- func (m *MemberMutation) SetRole(i int8) {
- m.role = &i
- m.addrole = nil
- }
- // Role returns the value of the "role" field in the mutation.
- func (m *MemberMutation) Role() (r int8, exists bool) {
- v := m.role
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRole returns the old "role" field's value of the Member entity.
- // If the Member object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *MemberMutation) OldRole(ctx context.Context) (v int8, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRole is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRole requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRole: %w", err)
- }
- return oldValue.Role, nil
- }
- // AddRole adds i to the "role" field.
- func (m *MemberMutation) AddRole(i int8) {
- if m.addrole != nil {
- *m.addrole += i
- } else {
- m.addrole = &i
- }
- }
- // AddedRole returns the value that was added to the "role" field in this mutation.
- func (m *MemberMutation) AddedRole() (r int8, exists bool) {
- v := m.addrole
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearRole clears the value of the "role" field.
- func (m *MemberMutation) ClearRole() {
- m.role = nil
- m.addrole = nil
- m.clearedFields[member.FieldRole] = struct{}{}
- }
- // RoleCleared returns if the "role" field was cleared in this mutation.
- func (m *MemberMutation) RoleCleared() bool {
- _, ok := m.clearedFields[member.FieldRole]
- return ok
- }
- // ResetRole resets all changes to the "role" field.
- func (m *MemberMutation) ResetRole() {
- m.role = nil
- m.addrole = nil
- delete(m.clearedFields, member.FieldRole)
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *MemberMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[member.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *MemberMutation) GroupCleared() bool {
- return m.GroupIDCleared() || m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *MemberMutation) GroupIDs() (ids []uuid.UUID) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *MemberMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the MemberMutation builder.
- func (m *MemberMutation) Where(ps ...predicate.Member) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the MemberMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *MemberMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Member, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *MemberMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *MemberMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Member).
- func (m *MemberMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *MemberMutation) Fields() []string {
- fields := make([]string, 0, 7)
- if m.created_at != nil {
- fields = append(fields, member.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, member.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, member.FieldDeletedAt)
- }
- if m.group != nil {
- fields = append(fields, member.FieldGroupID)
- }
- if m.ref_id != nil {
- fields = append(fields, member.FieldRefID)
- }
- if m._type != nil {
- fields = append(fields, member.FieldType)
- }
- if m.role != nil {
- fields = append(fields, member.FieldRole)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *MemberMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case member.FieldCreatedAt:
- return m.CreatedAt()
- case member.FieldUpdatedAt:
- return m.UpdatedAt()
- case member.FieldDeletedAt:
- return m.DeletedAt()
- case member.FieldGroupID:
- return m.GroupID()
- case member.FieldRefID:
- return m.RefID()
- case member.FieldType:
- return m.GetType()
- case member.FieldRole:
- return m.Role()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *MemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case member.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case member.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case member.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case member.FieldGroupID:
- return m.OldGroupID(ctx)
- case member.FieldRefID:
- return m.OldRefID(ctx)
- case member.FieldType:
- return m.OldType(ctx)
- case member.FieldRole:
- return m.OldRole(ctx)
- }
- return nil, fmt.Errorf("unknown Member field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *MemberMutation) SetField(name string, value ent.Value) error {
- switch name {
- case member.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case member.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case member.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case member.FieldGroupID:
- v, ok := value.(uuid.UUID)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case member.FieldRefID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefID(v)
- return nil
- case member.FieldType:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetType(v)
- return nil
- case member.FieldRole:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRole(v)
- return nil
- }
- return fmt.Errorf("unknown Member field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *MemberMutation) AddedFields() []string {
- var fields []string
- if m.add_type != nil {
- fields = append(fields, member.FieldType)
- }
- if m.addrole != nil {
- fields = append(fields, member.FieldRole)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *MemberMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case member.FieldType:
- return m.AddedType()
- case member.FieldRole:
- return m.AddedRole()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *MemberMutation) AddField(name string, value ent.Value) error {
- switch name {
- case member.FieldType:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddType(v)
- return nil
- case member.FieldRole:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRole(v)
- return nil
- }
- return fmt.Errorf("unknown Member numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *MemberMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(member.FieldDeletedAt) {
- fields = append(fields, member.FieldDeletedAt)
- }
- if m.FieldCleared(member.FieldGroupID) {
- fields = append(fields, member.FieldGroupID)
- }
- if m.FieldCleared(member.FieldRole) {
- fields = append(fields, member.FieldRole)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *MemberMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *MemberMutation) ClearField(name string) error {
- switch name {
- case member.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case member.FieldGroupID:
- m.ClearGroupID()
- return nil
- case member.FieldRole:
- m.ClearRole()
- return nil
- }
- return fmt.Errorf("unknown Member nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *MemberMutation) ResetField(name string) error {
- switch name {
- case member.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case member.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case member.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case member.FieldGroupID:
- m.ResetGroupID()
- return nil
- case member.FieldRefID:
- m.ResetRefID()
- return nil
- case member.FieldType:
- m.ResetType()
- return nil
- case member.FieldRole:
- m.ResetRole()
- return nil
- }
- return fmt.Errorf("unknown Member field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *MemberMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.group != nil {
- edges = append(edges, member.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *MemberMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case member.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *MemberMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *MemberMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *MemberMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedgroup {
- edges = append(edges, member.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *MemberMutation) EdgeCleared(name string) bool {
- switch name {
- case member.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *MemberMutation) ClearEdge(name string) error {
- switch name {
- case member.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown Member unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *MemberMutation) ResetEdge(name string) error {
- switch name {
- case member.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown Member edge %s", name)
- }
- // UserMutation represents an operation that mutates the User nodes in the graph.
- type UserMutation struct {
- config
- op Op
- typ string
- id *uuid.UUID
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- phone_number *string
- area_code *string
- email *string
- password *string
- is_registered *bool
- clearedFields map[string]struct{}
- userRefs map[int64]struct{}
- removeduserRefs map[int64]struct{}
- cleareduserRefs bool
- done bool
- oldValue func(context.Context) (*User, error)
- predicates []predicate.User
- }
- var _ ent.Mutation = (*UserMutation)(nil)
- // userOption allows management of the mutation configuration using functional options.
- type userOption func(*UserMutation)
- // newUserMutation creates new mutation for the User entity.
- func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
- m := &UserMutation{
- config: c,
- op: op,
- typ: TypeUser,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserID sets the ID field of the mutation.
- func withUserID(id uuid.UUID) userOption {
- return func(m *UserMutation) {
- var (
- err error
- once sync.Once
- value *User
- )
- m.oldValue = func(ctx context.Context) (*User, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().User.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUser sets the old User of the mutation.
- func withUser(node *User) userOption {
- return func(m *UserMutation) {
- m.oldValue = func(context.Context) (*User, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetID sets the value of the id field. Note that this
- // operation is only accepted on creation of User entities.
- func (m *UserMutation) SetID(id uuid.UUID) {
- m.id = &id
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserMutation) ID() (id uuid.UUID, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []uuid.UUID{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *UserMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *UserMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *UserMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[user.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *UserMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[user.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *UserMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, user.FieldDeletedAt)
- }
- // SetPhoneNumber sets the "phone_number" field.
- func (m *UserMutation) SetPhoneNumber(s string) {
- m.phone_number = &s
- }
- // PhoneNumber returns the value of the "phone_number" field in the mutation.
- func (m *UserMutation) PhoneNumber() (r string, exists bool) {
- v := m.phone_number
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPhoneNumber returns the old "phone_number" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldPhoneNumber(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPhoneNumber is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPhoneNumber requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPhoneNumber: %w", err)
- }
- return oldValue.PhoneNumber, nil
- }
- // ClearPhoneNumber clears the value of the "phone_number" field.
- func (m *UserMutation) ClearPhoneNumber() {
- m.phone_number = nil
- m.clearedFields[user.FieldPhoneNumber] = struct{}{}
- }
- // PhoneNumberCleared returns if the "phone_number" field was cleared in this mutation.
- func (m *UserMutation) PhoneNumberCleared() bool {
- _, ok := m.clearedFields[user.FieldPhoneNumber]
- return ok
- }
- // ResetPhoneNumber resets all changes to the "phone_number" field.
- func (m *UserMutation) ResetPhoneNumber() {
- m.phone_number = nil
- delete(m.clearedFields, user.FieldPhoneNumber)
- }
- // SetAreaCode sets the "area_code" field.
- func (m *UserMutation) SetAreaCode(s string) {
- m.area_code = &s
- }
- // AreaCode returns the value of the "area_code" field in the mutation.
- func (m *UserMutation) AreaCode() (r string, exists bool) {
- v := m.area_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAreaCode returns the old "area_code" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldAreaCode(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAreaCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAreaCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAreaCode: %w", err)
- }
- return oldValue.AreaCode, nil
- }
- // ClearAreaCode clears the value of the "area_code" field.
- func (m *UserMutation) ClearAreaCode() {
- m.area_code = nil
- m.clearedFields[user.FieldAreaCode] = struct{}{}
- }
- // AreaCodeCleared returns if the "area_code" field was cleared in this mutation.
- func (m *UserMutation) AreaCodeCleared() bool {
- _, ok := m.clearedFields[user.FieldAreaCode]
- return ok
- }
- // ResetAreaCode resets all changes to the "area_code" field.
- func (m *UserMutation) ResetAreaCode() {
- m.area_code = nil
- delete(m.clearedFields, user.FieldAreaCode)
- }
- // SetEmail sets the "email" field.
- func (m *UserMutation) SetEmail(s string) {
- m.email = &s
- }
- // Email returns the value of the "email" field in the mutation.
- func (m *UserMutation) Email() (r string, exists bool) {
- v := m.email
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEmail returns the old "email" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldEmail(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEmail is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEmail requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEmail: %w", err)
- }
- return oldValue.Email, nil
- }
- // ClearEmail clears the value of the "email" field.
- func (m *UserMutation) ClearEmail() {
- m.email = nil
- m.clearedFields[user.FieldEmail] = struct{}{}
- }
- // EmailCleared returns if the "email" field was cleared in this mutation.
- func (m *UserMutation) EmailCleared() bool {
- _, ok := m.clearedFields[user.FieldEmail]
- return ok
- }
- // ResetEmail resets all changes to the "email" field.
- func (m *UserMutation) ResetEmail() {
- m.email = nil
- delete(m.clearedFields, user.FieldEmail)
- }
- // SetPassword sets the "password" field.
- func (m *UserMutation) SetPassword(s string) {
- m.password = &s
- }
- // Password returns the value of the "password" field in the mutation.
- func (m *UserMutation) Password() (r string, exists bool) {
- v := m.password
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPassword returns the old "password" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldPassword(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPassword is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPassword requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPassword: %w", err)
- }
- return oldValue.Password, nil
- }
- // ClearPassword clears the value of the "password" field.
- func (m *UserMutation) ClearPassword() {
- m.password = nil
- m.clearedFields[user.FieldPassword] = struct{}{}
- }
- // PasswordCleared returns if the "password" field was cleared in this mutation.
- func (m *UserMutation) PasswordCleared() bool {
- _, ok := m.clearedFields[user.FieldPassword]
- return ok
- }
- // ResetPassword resets all changes to the "password" field.
- func (m *UserMutation) ResetPassword() {
- m.password = nil
- delete(m.clearedFields, user.FieldPassword)
- }
- // SetIsRegistered sets the "is_registered" field.
- func (m *UserMutation) SetIsRegistered(b bool) {
- m.is_registered = &b
- }
- // IsRegistered returns the value of the "is_registered" field in the mutation.
- func (m *UserMutation) IsRegistered() (r bool, exists bool) {
- v := m.is_registered
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIsRegistered returns the old "is_registered" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldIsRegistered(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIsRegistered is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIsRegistered requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIsRegistered: %w", err)
- }
- return oldValue.IsRegistered, nil
- }
- // ResetIsRegistered resets all changes to the "is_registered" field.
- func (m *UserMutation) ResetIsRegistered() {
- m.is_registered = nil
- }
- // AddUserRefIDs adds the "userRefs" edge to the ChildRef entity by ids.
- func (m *UserMutation) AddUserRefIDs(ids ...int64) {
- if m.userRefs == nil {
- m.userRefs = make(map[int64]struct{})
- }
- for i := range ids {
- m.userRefs[ids[i]] = struct{}{}
- }
- }
- // ClearUserRefs clears the "userRefs" edge to the ChildRef entity.
- func (m *UserMutation) ClearUserRefs() {
- m.cleareduserRefs = true
- }
- // UserRefsCleared reports if the "userRefs" edge to the ChildRef entity was cleared.
- func (m *UserMutation) UserRefsCleared() bool {
- return m.cleareduserRefs
- }
- // RemoveUserRefIDs removes the "userRefs" edge to the ChildRef entity by IDs.
- func (m *UserMutation) RemoveUserRefIDs(ids ...int64) {
- if m.removeduserRefs == nil {
- m.removeduserRefs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.userRefs, ids[i])
- m.removeduserRefs[ids[i]] = struct{}{}
- }
- }
- // RemovedUserRefs returns the removed IDs of the "userRefs" edge to the ChildRef entity.
- func (m *UserMutation) RemovedUserRefsIDs() (ids []int64) {
- for id := range m.removeduserRefs {
- ids = append(ids, id)
- }
- return
- }
- // UserRefsIDs returns the "userRefs" edge IDs in the mutation.
- func (m *UserMutation) UserRefsIDs() (ids []int64) {
- for id := range m.userRefs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUserRefs resets all changes to the "userRefs" edge.
- func (m *UserMutation) ResetUserRefs() {
- m.userRefs = nil
- m.cleareduserRefs = false
- m.removeduserRefs = nil
- }
- // Where appends a list predicates to the UserMutation builder.
- func (m *UserMutation) Where(ps ...predicate.User) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.User, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (User).
- func (m *UserMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserMutation) Fields() []string {
- fields := make([]string, 0, 8)
- if m.created_at != nil {
- fields = append(fields, user.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, user.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, user.FieldDeletedAt)
- }
- if m.phone_number != nil {
- fields = append(fields, user.FieldPhoneNumber)
- }
- if m.area_code != nil {
- fields = append(fields, user.FieldAreaCode)
- }
- if m.email != nil {
- fields = append(fields, user.FieldEmail)
- }
- if m.password != nil {
- fields = append(fields, user.FieldPassword)
- }
- if m.is_registered != nil {
- fields = append(fields, user.FieldIsRegistered)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case user.FieldCreatedAt:
- return m.CreatedAt()
- case user.FieldUpdatedAt:
- return m.UpdatedAt()
- case user.FieldDeletedAt:
- return m.DeletedAt()
- case user.FieldPhoneNumber:
- return m.PhoneNumber()
- case user.FieldAreaCode:
- return m.AreaCode()
- case user.FieldEmail:
- return m.Email()
- case user.FieldPassword:
- return m.Password()
- case user.FieldIsRegistered:
- return m.IsRegistered()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case user.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case user.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case user.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case user.FieldPhoneNumber:
- return m.OldPhoneNumber(ctx)
- case user.FieldAreaCode:
- return m.OldAreaCode(ctx)
- case user.FieldEmail:
- return m.OldEmail(ctx)
- case user.FieldPassword:
- return m.OldPassword(ctx)
- case user.FieldIsRegistered:
- return m.OldIsRegistered(ctx)
- }
- return nil, fmt.Errorf("unknown User field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserMutation) SetField(name string, value ent.Value) error {
- switch name {
- case user.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case user.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case user.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case user.FieldPhoneNumber:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPhoneNumber(v)
- return nil
- case user.FieldAreaCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAreaCode(v)
- return nil
- case user.FieldEmail:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEmail(v)
- return nil
- case user.FieldPassword:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPassword(v)
- return nil
- case user.FieldIsRegistered:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIsRegistered(v)
- return nil
- }
- return fmt.Errorf("unknown User field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown User numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(user.FieldDeletedAt) {
- fields = append(fields, user.FieldDeletedAt)
- }
- if m.FieldCleared(user.FieldPhoneNumber) {
- fields = append(fields, user.FieldPhoneNumber)
- }
- if m.FieldCleared(user.FieldAreaCode) {
- fields = append(fields, user.FieldAreaCode)
- }
- if m.FieldCleared(user.FieldEmail) {
- fields = append(fields, user.FieldEmail)
- }
- if m.FieldCleared(user.FieldPassword) {
- fields = append(fields, user.FieldPassword)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserMutation) ClearField(name string) error {
- switch name {
- case user.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case user.FieldPhoneNumber:
- m.ClearPhoneNumber()
- return nil
- case user.FieldAreaCode:
- m.ClearAreaCode()
- return nil
- case user.FieldEmail:
- m.ClearEmail()
- return nil
- case user.FieldPassword:
- m.ClearPassword()
- return nil
- }
- return fmt.Errorf("unknown User nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserMutation) ResetField(name string) error {
- switch name {
- case user.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case user.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case user.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case user.FieldPhoneNumber:
- m.ResetPhoneNumber()
- return nil
- case user.FieldAreaCode:
- m.ResetAreaCode()
- return nil
- case user.FieldEmail:
- m.ResetEmail()
- return nil
- case user.FieldPassword:
- m.ResetPassword()
- return nil
- case user.FieldIsRegistered:
- m.ResetIsRegistered()
- return nil
- }
- return fmt.Errorf("unknown User field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.userRefs != nil {
- edges = append(edges, user.EdgeUserRefs)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case user.EdgeUserRefs:
- ids := make([]ent.Value, 0, len(m.userRefs))
- for id := range m.userRefs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removeduserRefs != nil {
- edges = append(edges, user.EdgeUserRefs)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case user.EdgeUserRefs:
- ids := make([]ent.Value, 0, len(m.removeduserRefs))
- for id := range m.removeduserRefs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.cleareduserRefs {
- edges = append(edges, user.EdgeUserRefs)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserMutation) EdgeCleared(name string) bool {
- switch name {
- case user.EdgeUserRefs:
- return m.cleareduserRefs
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown User unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserMutation) ResetEdge(name string) error {
- switch name {
- case user.EdgeUserRefs:
- m.ResetUserRefs()
- return nil
- }
- return fmt.Errorf("unknown User edge %s", name)
- }
|