public checkExists()

in src/connectors/gremlin-connector.ts [80:100]


  public checkExists(type: Etype, id: string, callback: any) {
    if (!this.upsert || isNullOrUndefined(id)) {
      callback(null, false);
      return;
    }
    let query: string;
    if (type === Etype.vertex) {
      query = `g.V().hasId('${id}').count()`;
    } else {
      query = `g.E().hasId('${id}').count()`;
    }
    async.asyncify(() => this.client.submit(query))(
      (err: any, res: number[]) => {
        let exists = false;
        if (res && res.length > 0 && res[0] > 0) {
          exists = true;
        }
        callback(err, exists);
      }
    );
  }