You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constadmin=vault.field<Admin>('admin')admin.get()// Promise<Admin>// only with the full accessadmin.set(admin)// Promise<void>
Collections
constusers=vault.collection<User>('users')users.getAll()// Promise<User[]>users.getOne(user=>user.id===123)// Promise<User | null>// only with the full accessusers.setAll(users)// Promise<void>users.addOne(user)// Promise<User>users.updateOne(user=>user.id===123,{age: 27/* пажилой */})// Promise<User | null>users.updateOne(user=>user.id===123,user=>({age: user.age+1}))// Promise<User | null>users.updateAll(user=>user.id===123,{age: 27/* пажилые */})// Promise<User[]>users.updateAll(user=>user.id===123,user=>({age: user.age+1}))// Promise<User[]>users.deleteOne(user=>user.id===321)// Promise<User | null>users.deleteAll(user=>user.id===321)// Promise<User[]>
Serialization
/* * In this example, the user ids are stored in the Vault as strings * We transform them to numbers using the 'deserialize' option * So, we can work with values in a form convenient for us * To transform them back to original form use the 'serialize' option *//* * The first generic - target type (original value processed by 'deserialize') * The second generic - source type (original value from Vault and 'serialize' result) */constuserIds=vault.collection<number,string>('users',{serialize: String,deserialize: Number})