How to use the @bentley/imodeljs-backend.IModelDb.openSnapshot function in @bentley/imodeljs-backend

To help you get started, we’ve selected a few @bentley/imodeljs-backend 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 / example-code / snippets / src / backend / ExecutingECSQL.ts View on Github external
console.log("ECClassId | Parent RelECClassId");
    while (stmt.step() === DbResult.BE_SQLITE_ROW) {
      const classIdValue: ECSqlValue = stmt.getValue(0);
      const parentRelClassIdValue: ECSqlValue = stmt.getValue(1);

      const classId: string = classIdValue.getId();
      const parentRelClassId: string = parentRelClassIdValue.getId();

      console.log(classId + "|" + parentRelClassId);
    }
  });
  // __PUBLISH_EXTRACT_END__
}

const dummyIModel = IModelDb.openSnapshot("");
executeECSql_Binding(dummyIModel);
executeECSql_QueryResult(dummyIModel);
github imodeljs / imodeljs / test-apps / presentation-integration-tests / src / backend / RulesetsEmbedding.tests.ts View on Github external
function createSnapshotFromSeed(testFileName: string, seedFileName: string): IModelDb {
    const seedDb: IModelDb = IModelDb.openSnapshot(seedFileName);
    const testDb: IModelDb = seedDb.createSnapshot(testFileName);
    seedDb.closeSnapshot();
    return testDb;
  }
github imodeljs / imodeljs / test-apps / export-obj / src / ExportObj.ts View on Github external
function doExport(iModelName: string, objName: string, mtlName: string) {
  IModelHost.startup();
  Logger.initializeToConsole();
  Logger.setLevelDefault(LogLevel.Error);

  const iModel: IModelDb = IModelDb.openSnapshot(iModelName);
  process.stdout.write(`Opened ${iModelName} successfully.\n`);

  const objFile = fs.openSync(objName, "w");
  const mtlFile = fs.openSync(mtlName, "w");
  process.stdout.write(`Writing to ${objName} and ${mtlName}.\n`);

  const elementIdArray: Id64Array = [];
  iModel.withPreparedStatement("SELECT ECInstanceId FROM bis.GeometricElement3d", (stmt: ECSqlStatement) => {
    while (stmt.step() === DbResult.BE_SQLITE_ROW) {
      elementIdArray.push(stmt.getValue(0).getId());
    }
  });

  process.stdout.write(`Processing ${elementIdArray.length} elements...\n`);
  if (elementIdArray.length === 0)
    return;
github imodeljs / imodeljs / test-apps / export-gltf / src / ExportGltf.ts View on Github external
public static initialize(iModelName: string, gltfName: string) {
    GltfGlobals.iModel = IModelDb.openSnapshot(iModelName);
    process.stdout.write(`Opened ${iModelName} successfully...\n`);

    const gltfPathParts = path.parse(gltfName);
    const binName = gltfPathParts.name + ".bin";
    GltfGlobals.binFile = fs.openSync(path.join(gltfPathParts.dir, binName), "w");
    GltfGlobals.texturesDir = gltfPathParts.dir;
    process.stdout.write(`Writing to ${gltfName} and ${binName}...\n`);

    GltfGlobals.gltf = {
      accessors: [],
      asset: {
        generator: "iModel.js export-gltf",
        version: "2.0",
      },
      buffers: [{ uri: binName, byteLength: 0 }],
      bufferViews: [],