How to use @bentley/imodeljs-native - 8 common examples

To help you get started, we’ve selected a few @bentley/imodeljs-native 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 imodeljs / imodeljs / core / backend / src / IModelHost.ts View on Github external
public static load(dir?: string): typeof IModelJsNative {
    return this.isMobile ? this.imodeljsMobile.imodeljsNative : // we are running on a mobile platform
      require("@bentley/imodeljs-native/loadNativePlatform.js").loadNativePlatform(dir); // We are running in node or electron.
  }
}
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
const poll = () => {
          if (!this.isOpen) {
            resolve({ status: QueryResponseStatus.Done, rows: [] });
          } else {
            const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
            if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
              resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
              resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
              resolve({ status: QueryResponseStatus.Timeout, rows: [] });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
              setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
            else
              resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
          }
        };
        setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
github imodeljs / imodeljs / core / backend / src / ECDb.ts View on Github external
return new Promise((resolve) => {
      const postrc = this.nativeDb.postConcurrentQuery(ecsql, JSON.stringify(bindings, replacer), limit!, quota!, priority!);
      if (postrc.status !== IModelJsNative.ConcurrentQuery.PostStatus.Done)
        resolve({ status: QueryResponseStatus.PostError, rows: [] });

      const poll = () => {
        if (!this.nativeDb || !this.nativeDb.isOpen()) {
          resolve({ status: QueryResponseStatus.Done, rows: [] });
        } else {
          const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
          if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
            resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
            resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
            resolve({ status: QueryResponseStatus.Timeout, rows: [] });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
            setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
          else
github imodeljs / imodeljs / core / backend / src / ECDb.ts View on Github external
const poll = () => {
        if (!this.nativeDb || !this.nativeDb.isOpen()) {
          resolve({ status: QueryResponseStatus.Done, rows: [] });
        } else {
          const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
          if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
            resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
            resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
            resolve({ status: QueryResponseStatus.Timeout, rows: [] });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
            setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
          else
            resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
        }
      };
      setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
const poll = () => {
          if (!this.isOpen) {
            resolve({ status: QueryResponseStatus.Done, rows: [] });
          } else {
            const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
            if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
              resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
              resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
              resolve({ status: QueryResponseStatus.Timeout, rows: [] });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
              setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
            else
              resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
          }
        };
        setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
return new Promise((resolve) => {
      if (!this.isOpen) {
        resolve({ status: QueryResponseStatus.Done, rows: [] });
      } else {
        const postrc = this.nativeDb.postConcurrentQuery(ecsql, JSON.stringify(bindings, replacer), limit!, quota!, priority!);
        if (postrc.status !== IModelJsNative.ConcurrentQuery.PostStatus.Done)
          resolve({ status: QueryResponseStatus.PostError, rows: [] });
        const poll = () => {
          if (!this.isOpen) {
            resolve({ status: QueryResponseStatus.Done, rows: [] });
          } else {
            const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
            if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
              resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
              resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
              resolve({ status: QueryResponseStatus.Timeout, rows: [] });
            else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
              setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
            else
              resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
github imodeljs / imodeljs / core / backend / src / ECDb.ts View on Github external
const poll = () => {
        if (!this.nativeDb || !this.nativeDb.isOpen()) {
          resolve({ status: QueryResponseStatus.Done, rows: [] });
        } else {
          const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
          if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
            resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
            resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
            resolve({ status: QueryResponseStatus.Timeout, rows: [] });
          else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
            setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
          else
            resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
        }
      };
      setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
public static performUpgrade(pathname: string): DbResult {
    const nativeDb = new IModelHost.platform.DgnDb();
    const res = nativeDb.openIModel(pathname, OpenMode.ReadWrite, IModelJsNative.UpgradeOptions.Upgrade);
    if (DbResult.BE_SQLITE_OK === res)
      nativeDb.closeIModel();
    return res;
  }