@based/core-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@based/core

import { BasedCoreClient } from '@based/core-client'

// create client
const coreClient = new BasedCoreClient()

// connect
coreClient.connect({
  env: 'myEnv',
  org: 'myOrg',
  project: 'myProject'
})

coreClient.once('connect', (isConnected) => {
  console.info('connect', isConnected)
})

// authorize
const authState = await coreClient.auth(token)

// update schema
await coreClient.function('based-db-update-schema', {
  languages: ['en'],
  types: {
    thing: {
      prefix: 'th',
      fields: {
        name: { type: 'string' },
      },
    },
  },
})

// observe
coreClient.observe(
   'based-db-observe',
   (d) => {
     console.info('|-->', d)
   },
   { children: { name: true, id: true, $list: true } }
 )

// set (or any function)
const res = await coreClient.function('based-db-set', {
  type: 'thing',
  name: 'BLAAAA',
})

// get from observer
const res = await coreClient.get('based-db-observe')

Dependents (0)

Package Sidebar

Install

npm i @based/core-client

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

85.6 kB

Total Files

57

Last publish

Collaborators

  • luiguild
  • nfrade
  • kylemarch513
  • framma
  • olliv
  • youzid
  • rase-
  • saulx