Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
iModelDb.withPreparedStatement("SELECT ECInstanceId FROM ecchange.change.InstanceChange WHERE Summary.Id=?", (statement) => {
statement.bindId(1, changeSummary.id);
while (statement.step() === DbResult.BE_SQLITE_ROW) {
const instanceId: Id64String = statement.getValue(0).getId();
const instanceChange: InstanceChange = ChangeSummaryManager.queryInstanceChange(iModelDb, instanceId);
const entityClassFullName: string = EntityChangeOps._toClassFullName(instanceChange.changedInstance.className);
try {
const entityType: typeof Entity = iModelDb.getJsClass(entityClassFullName);
if (entityType.prototype instanceof Element) {
// const propertyNames: string[] = ChangeSummaryManager.getChangedPropertyValueNames(iModelDb, instanceChange.id);
entityChanges.elements.addChange(instanceChange.opCode, instanceChange.changedInstance.id);
} else if (entityType.prototype instanceof ElementAspect) {
entityChanges.elementAspects.addChange(instanceChange.opCode, instanceChange.changedInstance.id);
} else if (entityType.prototype instanceof Model) {
entityChanges.models.addChange(instanceChange.opCode, instanceChange.changedInstance.id);
} else if (entityType.prototype instanceof Relationship) {
entityChanges.relationships.addChange(instanceChange.opCode, instanceChange.changedInstance.id);
}
} catch (error) {
iModel.withPreparedStatement("SELECT ECInstanceId,ECClassId,Parent,LastMod FROM bis.Element WHERE CodeValue=? AND LastMod>=?", (stmt: ECSqlStatement) => {
stmt.bindString(1, "MyCode");
stmt.bindDateTime(2, "2018-01-01T12:00:00");
while (stmt.step() === DbResult.BE_SQLITE_ROW) {
// do something with the query result
}
});
// __PUBLISH_EXTRACT_END__
iModel.withPreparedStatement("SELECT ECInstanceId FROM bis.GeometricElement3d", (stmt: ECSqlStatement) => {
while (stmt.step() === DbResult.BE_SQLITE_ROW) {
elementIdArray.push(stmt.getValue(0).getId());
}
});
return this._iModel.withPreparedStatement(sql, (statement: ECSqlStatement): ElementAspect[] => {
statement.bindId("elementId", elementId);
const aspects: ElementAspect[] = [];
while (DbResult.BE_SQLITE_ROW === statement.step()) {
const row: any = statement.getRow();
aspects.push(this._queryAspect(row.id, row.className.replace(".", ":")));
}
return aspects;
});
}
public next(): IteratorResult {
if (DbResult.BE_SQLITE_ROW === this.step()) {
return {
done: false,
value: this.getRow(),
};
} else {
return {
done: true,
value: undefined,
};
}
}
(stmt: ECSqlStatement) => {
stmt.bindString(1, changeSetId);
if (DbResult.BE_SQLITE_ROW === stmt.step())
return stmt.getValue(0).getId();
return undefined;
});
}
return this._iModel.withPreparedStatement(`SELECT * FROM ${relClassSqlName} WHERE ecinstanceid=?`, (stmt: ECSqlStatement) => {
stmt.bindId(1, criteria);
if (DbResult.BE_SQLITE_ROW !== stmt.step())
throw new IModelError(IModelStatus.NotFound, "LinkTableRelationship not found", Logger.logWarning, loggingCategory);
return stmt.getRow() as LinkTableRelationshipProps;
});
}
props = this._iModel.withPreparedStatement("SELECT * FROM " + relClassSqlName + " WHERE SourceECInstanceId=? AND TargetECInstanceId=?", (stmt: ECSqlStatement) => {
stmt.bindId(1, criteria.sourceId);
stmt.bindId(2, criteria.targetId);
if (DbResult.BE_SQLITE_ROW !== stmt.step())
throw new IModelError(IModelStatus.NotFound, "Relationship not found", Logger.logWarning, loggerCategory);
return stmt.getRow() as T;
});
}
imodel.withPreparedStatement(query, (stmt) => {
stmt.bindId(1, id);
if (stmt.step() === DbResult.BE_SQLITE_ROW)
key = { className: stmt.getValue(0).getClassNameForClassId().replace(".", ":"), id };
});
return key;