0

I'm new to Dgraph and am bashing my head against a simple issue with dgraph-js. I've even pored through the github sourcecode but I've clearly missed what I'm looking for.

Within the dgraph-ratel interface I can run this query:

schema(pred: [name]) {
  type
  index
}

or even just

schema {}

to get schema information about the database. But within dgraph-js if I use the query transaction, it works fine for normal queries:

const res = await this.connection.newTxn().query(`query {
    getData(func: regexp(name, /.*mic+.*/i)) {
        name
    }
}`);
const data = res.getJson();

but running the following:

const res = await this.connection.newTxn().query(`schema {}`);
const data = res.getJson();

returns an empty object. I suspect that I shouldn't be using newTxn().query() but something else. Should it be a new dGraph.Operation()? Or maybe something else? Where can I see all the functions available to me? The readme on the dgraph-js (https://github.com/dgraph-io/dgraph-js) only provides so much information...

1 Answer 1

2

you can use

res.getSchemaList();

As you can find in https://github.com/dgraph-io/dgraph-js/blob/18fa97c66bf9a2c897bf77ded119c1d1cb79333e/generated/api_pb.d.ts#L46

Cheers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.