Skip to main content

Pull & Push

Instantiated data models with @dataclass decorator can be pushed to and pulled from the remote datastores defined in the application.

Operations

  • Push: Sending local data changes to the remote datastore.
  • Pull: Retrieving the latest data from the remote datastore to update local objects.
import { push, pull } from 'ts-basis'

// Push to remote
const newUser = new User({ name: 'Alice', id: 'test' })
await push(newUser)

// Pull updates
await pull(newUser)

// Getting User through an index (returns null if not found)
const aliceUser = await User.index.byId.get({ id: 'test' })