How to use the rethinkdb.do function in rethinkdb

To help you get started, we’ve selected a few rethinkdb 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 reindexio / reindex-api / db / rethinkdb / queries / indexes.js View on Github external
export function cursorToIndexKey(
  type,
  index,
  cursor,
  keyPrefix,
  paddingSize,
  defaultValue,
) {
  if (cursor) {
    // Valid cursor is always enough, we retrieve the object it points to
    // to get between data
    return RethinkDB.do(
      RethinkDB.table(type).get(cursor.value),
      (result) => RethinkDB.branch(
        result,
        getIndexValue(result, index.fields),
        defaultValue
      )
    );
  } else if (keyPrefix) {
    // No cursor passed, we create between data from data we already have
    // and pad the unavailable values with base (either minval or maxval)
    return [
      ...keyPrefix,
      ...(new Array(paddingSize).fill(defaultValue)),
    ];
  } else {
    return defaultValue;
github reindexio / reindex-api / query / mutators / RemoveTypeMutator.js View on Github external
toReQL(db) {
    return RethinkDB.do(db.table(TYPE_TABLE).get(this.name).delete({
      returnChanges: true,
    }), (result) => {
      return RethinkDB.do(db.tableDrop(this.name), () => {
        return result('changes')(0)('old_val');
      });
    });
  }
}
github reindexio / reindex-api / db / rethinkdb / queries / mutationQueries.js View on Github external
export function createType(conn, type) {
  if (type.interfaces.includes('Node')) {
    return queryWithIDs('ReindexType', RethinkDB.do(
      RethinkDB.tableCreate(type.name),
      () => getCreateQuery('ReindexType', type)
    )).run(conn);
  } else {
    return create(conn, 'ReindexType', type);
  }
}
github reindexio / reindex-api / query / mutators / RemoveConnectionMutator.js View on Github external
toReQL(db) {
    return RethinkDB.do(
      db.table(TYPE_TABLE).get(this.tableName).update((type) => ({
        fields: type('fields').difference(
          type('fields').filter({name: this.name})
        ),
        indexes: type('indexes').difference(
          type('indexes').filter({name: this.name})
        ),
      }), {
        returnChanges: true,
      }),
      db.table(TYPE_TABLE).get(this.targetName).update((type) => ({
        fields: type('fields').difference(
          type('fields').filter({name: this.reverseName})
        ),
      }), {
        returnChanges: true,
github reindexio / reindex-api / db / rethinkdb / queries / simpleQueries.js View on Github external
export async function getMetadata(conn) {
  const result = await RethinkDB.do(
    queryWithIDs(TYPE_TABLE, RethinkDB.table(TYPE_TABLE)).coerceTo('array'),
    queryWithIDs(INDEX_TABLE, RethinkDB.table(INDEX_TABLE)).coerceTo('array'),
    queryWithIDs(HOOK_TABLE, RethinkDB.table(HOOK_TABLE)).coerceTo('array'),
    (types, indexes, hooks) => ({
      types,
      indexes,
      hooks,
    })
  ).run(conn);
  result.types = result.types.map((type) => {
    type.fields = injectDefaultFields(type);
    return type;
  });
  return result;
}
github reindexio / reindex-api / db / rethinkdb / migrations / 0001_createReindexHook.js View on Github external
async function main() {
  await runMigration([
    RethinkDB.do(
      RethinkDB.tableList(),
      (tables) =>
        RethinkDB.branch(
          tables.contains('ReindexHook'),
          {},
          RethinkDB.tableCreate('ReindexHook')
        )
    ),
  ]);
}
github jmdobry / RequelPro / src / RequelPro / models / table.js View on Github external
getFieldsAndTypes() {
      return this.connection.run(
        r.do(r.db(this.database.name).table(this.name).sample(500).coerceTo('array'), rows => {
          return rows.concatMap(_row => _row.keys())
            .distinct()
            .map(field => {
              return {
                name: field,
                types: rows.group(_row => _row(field).default(null).typeOf()).count().ungroup().coerceTo('array')
              };
            });
        })
      );
    }
  }
github reindexio / reindex-api / db / rethinkdb / queries / mutationQueries.js View on Github external
    (result) => RethinkDB.do(
      RethinkDB.branch(
        result('interfaces').contains('Node'),
        RethinkDB.tableDrop(result('name')),
        {}
      ),
      () => result
    )
  )).run(conn);
github reindexio / reindex-api / query / mutators / RemoveTypeMutator.js View on Github external
}), (result) => {
      return RethinkDB.do(db.tableDrop(this.name), () => {
        return result('changes')(0)('old_val');
      });
    });
  }

rethinkdb

This package provides the JavaScript driver library for the RethinkDB database server for use in your node application.

Unknown
Latest version published 4 years ago

Package Health Score

61 / 100
Full package analysis