How to use the dgraph-js.Operation function in dgraph-js

To help you get started, we’ve selected a few dgraph-js 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 dgraph-io / dgraph-js / examples / simple / index.js View on Github external
async function dropAll(dgraphClient) {
    const op = new dgraph.Operation();
    op.setDropAll(true);
    await dgraphClient.alter(op);
}
github dgraph-io / dgraph-js / examples / tls / index.js View on Github external
async function setSchema(dgraphClient) {
    const schema = `
        name: string @index(exact) .
        age: int .
        married: bool .
        loc: geo .
        dob: datetime .
        friend: [uid] @reverse .
    `;
    const op = new dgraph.Operation();
    op.setSchema(schema);
    await dgraphClient.alter(op);
}
github astroband / astrograph / src / dgraph.ts View on Github external
const dropAll = async () => {
  const op = new Operation();
  op.setDropAll(true);
  await client.alter(op);
}
github dgraph-io / dgraph-js / examples / tls / index.js View on Github external
async function dropAll(dgraphClient) {
    const op = new dgraph.Operation();
    op.setDropAll(true);
    await dgraphClient.alter(op);
}
github dgraph-io / dgraph-js / examples / simple / index-pre-v7.6.js View on Github external
function setSchema(dgraphClient) {
    const schema = `
        name: string @index(exact) .
        age: int .
        married: bool .
        loc: geo .
        dob: datetime .
    `;
    const op = new dgraph.Operation();
    op.setSchema(schema);
    return dgraphClient.alter(op);
}
github dgraph-io / dgraph-js / examples / simple / index-pre-v7.6.js View on Github external
function dropAll(dgraphClient) {
    const op = new dgraph.Operation();
    op.setDropAll(true);
    return dgraphClient.alter(op);
}
github dpeek / dgraphql / src / client.js View on Github external
async updateSchema (schema: string) {
    const ast = transformSchema(parse(new Source(schema)), this.relay)
    const info = getInfo(ast)

    let gql = ''
    for (var [key, value] of info) {
      gql += key + ': ' + value.type
      if (value.indexes.size) {
        gql += ' @index(' + [...value.indexes].join(',') + ')'
      }
      gql += ' .\n'
    }

    const op = new Operation()
    op.setSchema(gql)
    await client.alter(op)

    const version = 1
    schema = schema.replace(/\n/g, '\\n')
    schema = schema.replace(/"/g, '\\"')
    let sets = `_:node  "" .\n`
    sets += `_:node <__typename> "${updateTypeName}" .\n`
    sets += `_:node  "${schema}" .\n`
    sets += `_:node  "${version}" .\n`
    const mutation = new Mutation()
    mutation.setCommitNow(true)
    mutation.setSetNquads(new Uint8Array(new Buffer(sets)))
    const txn = client.newTxn()
    await txn.mutate(mutation)
  }
github gverse / gverse / src / gverse / connection.ts View on Github external
async applySchema(schema: string, retries = 0): Promise {
    try {
      log("Apply schema take", retries, "schema: ", schema)
      const op = new dgraph.Operation()
      op.setSchema(schema)
      await this.client.alter(op)
    } catch (e) {
      if (shouldRetry(e, retries)) {
        await waitPromise(`schema ${schema}`)
        return await this.applySchema(schema, retries + 1)
      } else {
        log(e)
        throw Error(e)
      }
    }
  }
  async disconnect() {

dgraph-js

Official javascript client for Dgraph

Apache-2.0
Latest version published 9 days ago

Package Health Score

79 / 100
Full package analysis

Similar packages