The value types that have no type constraints.
The value types to use for set operation.
The value types to use for update operation.
The value types to use for upset operation.
The array remove value type. It holds the data to remove from the target array.
The array union value type. It holds the payload to union.
The increment value type. It holds the increment value.
Available value kinds.
The remove value type.
The server date value type.
Creates a value object.
import { value, set, update, collection } from 'typesaurus'
type User = {
name: string,
friends: number
interests: string[]
registrationDate: Date
note?: string
}
const users = collection<User>('users')
(async () => {
await set(users, '00sHm46UWKObv2W7XK9e', {
name: 'Sasha',
friends: 123,
interests: ['snowboarding', 'surfboarding', 'running'],
// Set server date value to the field
registrationDate: value('serverDate')
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Add 2 to the value
friends: value('increment', 2),
// Remove 'running' from the interests
interests: value('arrayRemove', ['running']),
note: 'Demo'
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Remove the field
note: value('remove')
// Add values to the interests
interests: value('arrayUnion', ['skateboarding', 'minecraft'])
})
})()
The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')
Creates a value object.
import { value, set, update, collection } from 'typesaurus'
type User = {
name: string,
friends: number
interests: string[]
registrationDate: Date
note?: string
}
const users = collection<User>('users')
(async () => {
await set(users, '00sHm46UWKObv2W7XK9e', {
name: 'Sasha',
friends: 123,
interests: ['snowboarding', 'surfboarding', 'running'],
// Set server date value to the field
registrationDate: value('serverDate')
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Add 2 to the value
friends: value('increment', 2),
// Remove 'running' from the interests
interests: value('arrayRemove', ['running']),
note: 'Demo'
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Remove the field
note: value('remove')
// Add values to the interests
interests: value('arrayUnion', ['skateboarding', 'minecraft'])
})
})()
The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')
Creates a value object.
import { value, set, update, collection } from 'typesaurus'
type User = {
name: string,
friends: number
interests: string[]
registrationDate: Date
note?: string
}
const users = collection<User>('users')
(async () => {
await set(users, '00sHm46UWKObv2W7XK9e', {
name: 'Sasha',
friends: 123,
interests: ['snowboarding', 'surfboarding', 'running'],
// Set server date value to the field
registrationDate: value('serverDate')
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Add 2 to the value
friends: value('increment', 2),
// Remove 'running' from the interests
interests: value('arrayRemove', ['running']),
note: 'Demo'
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Remove the field
note: value('remove')
// Add values to the interests
interests: value('arrayUnion', ['skateboarding', 'minecraft'])
})
})()
The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')
The payload if required by the kind
Creates a value object.
import { value, set, update, collection } from 'typesaurus'
type User = {
name: string,
friends: number
interests: string[]
registrationDate: Date
note?: string
}
const users = collection<User>('users')
(async () => {
await set(users, '00sHm46UWKObv2W7XK9e', {
name: 'Sasha',
friends: 123,
interests: ['snowboarding', 'surfboarding', 'running'],
// Set server date value to the field
registrationDate: value('serverDate')
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Add 2 to the value
friends: value('increment', 2),
// Remove 'running' from the interests
interests: value('arrayRemove', ['running']),
note: 'Demo'
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Remove the field
note: value('remove')
// Add values to the interests
interests: value('arrayUnion', ['skateboarding', 'minecraft'])
})
})()
The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')
The payload if required by the kind
Creates a value object.
import { value, set, update, collection } from 'typesaurus'
type User = {
name: string,
friends: number
interests: string[]
registrationDate: Date
note?: string
}
const users = collection<User>('users')
(async () => {
await set(users, '00sHm46UWKObv2W7XK9e', {
name: 'Sasha',
friends: 123,
interests: ['snowboarding', 'surfboarding', 'running'],
// Set server date value to the field
registrationDate: value('serverDate')
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Add 2 to the value
friends: value('increment', 2),
// Remove 'running' from the interests
interests: value('arrayRemove', ['running']),
note: 'Demo'
})
await update(users, '00sHm46UWKObv2W7XK9e', {
// Remove the field
note: value('remove')
// Add values to the interests
interests: value('arrayUnion', ['skateboarding', 'minecraft'])
})
})()
The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')
Generated using TypeDoc
The value types to use for add operation.