user-spec Pub Share

Users persistence

Call on startup: if no users in elk, migrate automatically

$when:: diesel.users.impl.checkAndMigrateToElk
   diesel.users.init
   diesel.users.impl.findUserByEmailEnc (email=""="")
   $ifc:: (payload[="total"] <= 0) do.this
     diesel.mod.user.setPersist (class ="model.UsersPersistMongo"...="model.Use...)
     diesel.mod.user.migrateLower
     diesel.mod.user.setPersist (class ="razie.wiki.util.UsersPersistDi"...="razie.wik...)
     diesel.mod.user.migrateToElk

$when:: diesel.users.impl.findUserByEmailDec (email)
   diesel.users.impl.findUserByEmailEnc (email=enc(email))

$when:: diesel.users.impl.findUserByEmailEnc (email)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={email:ema...)

$when:: diesel.users.impl.findUserByApiKey (apiKey)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={apiKey:ap...)

$when:: diesel.users.impl.findUserById (id)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={_id:id,_i...)

$when:: diesel.users.impl.findUserByUsername (userName)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={userName:...)

$when:: diesel.users.impl.nameOf (id)
   diesel.users.impl.findUserById (id)
   . (payload=(payload[="data"] map ( x=>x="userName" )))

$when:: diesel.users.impl.findUserNoCase (uncEmail)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={emailLowe...)

$when:: diesel.users.impl.findUsersForRealm (realm)
   diesel.inv.query (className="DieselUser"="DieselUse..., query :JSON={realms:re...)

$when:: diesel.users.impl.findProfileByUserId (userId)
   diesel.inv.query (className="DieselUserProfile"="DieselUse..., query :JSON={mongoUser...)

Update

$when:: diesel.users.impl.createProfile (profile)
   . (j=(profile as json))
   . (j[="mongoUserId"]=j[="userId"][="$oid"="$oid"], j[="mongoId"]=j[="_id"], j[="key"]=j[="_id"][="$oid"="$oid"])
   diesel.inv.upsert (className="DieselUserProfile"="DieselUse..., entity=j)

$when:: diesel.users.impl.updateProfile (profile)
   diesel.inv.upsert (className="DieselUserProfile"="DieselUse..., entity=(profile a...)

$when:: diesel.users.impl.updateUser (oldUser, newUser)
   . (j=(newUser as json))
   $ifc:: (j[="_id"][="$oid"="$oid"] is defined) . (j[="mongoId"]=j[="_id"], j[="key"]=j[="_id"][="$oid"="$oid"])
   diesel.inv.upsert (className="DieselUser"="DieselUse..., entity=j)

$when:: diesel.users.impl.createUser (user)
   . (j=(user as json))
   . (j[="mongoId"]=j[="_id"], j[="key"]=j[="_id"][="$oid"="$oid"])
   diesel.inv.upsert (className="DieselUser"="DieselUse..., entity=j)

$when:: diesel.users.init
   diesel.inv.register (inventory="diesel.elk"="diesel.el..., classNames ="DieselUser,DieselUserProfile"...="DieselUse...)
   diesel.inv.connect (inventory="diesel.elk"="diesel.el..., env=diesel[="e..., connection="", super="diesel"="diesel")
   diesel.mod.user.setPersist (class ="razie.wiki.util.UsersPersistDi"...="razie.wik...)


Was this useful?    

By: Razie | 2023-02-22 .. 2023-06-05 | Tags: spec , dsl


Viewed 425 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.