How to use rethinkdb-ts - 10 common examples

To help you get started, we’ve selected a few rethinkdb-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rethinkdb / rethinkdb-desktop / app / main / db / queries / stats.js View on Github external
const getServerStats = () => {
  const serverConfig = sysTable('server_config')
  const serverStatus = sysTable('server_status')
  const tableConfig = sysTable('table_config')

  return r
    .do(
      serverConfig.nth(0),
      // All connected servers
      serverStatus('name').coerceTo('array'),
      // All servers assigned to tables
      tableConfig
        .concatMap(row => row('shards').default([]))
        .concatMap(row => row('replicas'))
        .distinct(),
      (server, connectedServers, assignedServers) => ({
        server,
        serversConnected: connectedServers.count(),
        serversMissing: assignedServers.setDifference(connectedServers),
        unknownMissing: tableConfig
          .filter(row => row.hasFields('shards').not())('name')
          .isEmpty()
github rethinkdb / rethinkdb-desktop / app / main / db / queries / logs.js View on Github external
function getLogs () {
  return r
    .db(SYSTEM_DB)
    .table('logs')
    .limit(10)
    .coerceTo('array')
    .run(connection())
}
github rethinkdb / rethinkdb-desktop / app / main / db / driver.js View on Github external
connect: async function (config = {}) {
    if (connection) {
      console.info('there is an active connection - closing current connection')
      await driver.disconnect()
      console.info('closed')
    }
    console.info('new connection request')
    connection = await r.connect(config)
    console.info('connected')
    return connection
  },
  async disconnect () {
github rethinkdb / rethinkdb-desktop / app / main / db / queries / server.js View on Github external
const serverList = () => {
  return r
    .db('rethinkdb')
    .table('stats')
    .filter(row =>
      row('id')
        .nth(0)
        .eq('server')
    )
    .coerceTo('array')
}
github rethinkdb / rethinkdb-desktop / app / main / db / queries / database.js View on Github external
const addDatabase = ({ name }) => {
  return r
    .db(SYSTEM_DB)
    .table('db_config')
    .insert({ name })
    .run(connection())
}
github rethinkdb / rethinkdb-desktop / app / main / db / queries / table.js View on Github external
const deleteTables = tablesToDelete => {
  return r
    .db(SYSTEM_DB)
    .table('table_config')
    .filter(table => {
      return r.expr(tablesToDelete).contains({
        db: table('db'),
        name: table('name')
      })
    })
    .delete({ returnChanges: true })
    .run(connection())
}
github rethinkdb / rethinkdb-desktop / app / main / db / queries / table.js View on Github external
.do(servers => {
      return r.branch(
        servers.isEmpty(),
        r.error('No server is connected'),
        servers
          .sample(1)
          .nth(0)('name')
          .do(server => {
            return r
              .db(SYSTEM_DB)
              .table('table_config')
              .insert(
                {
                  db,
                  name,
                  primary_key: primaryKey,
                  durability,
                  shards: [
github rethinkdb / rethinkdb-desktop / app / main / db / queries / database.js View on Github external
const deleteDatabase = ({ name }) => {
  return r.dbDrop(name).run(connection())
}
github rethinkdb / rethinkdb-desktop / app / main / db / queries / table.js View on Github external
.do(servers => {
      return r.branch(
        servers.isEmpty(),
        r.error('No server is connected'),
        servers
          .sample(1)
          .nth(0)('name')
          .do(server => {
            return r
              .db(SYSTEM_DB)
              .table('table_config')
              .insert(
                {
                  db,
                  name,
                  primary_key: primaryKey,
                  durability,
                  shards: [
                    {
                      primary_replica: server,

rethinkdb-ts

RethinkDB TypeScript driver

Apache-2.0
Latest version published 3 months ago

Package Health Score

73 / 100
Full package analysis

Similar packages