UNPKG

mssql-change-tracking

Version:
21 lines 1.02 kB
import { writeLog } from "fast-node-logger"; /** @description this function is used to obtain the current version that will be used the next time when querying changes. This version represents the version of the last committed transaction. */ export async function ctCurrentVersion({ pool, dbName, }) { writeLog(`ctCurrentVersion`, { level: "trace" }); return pool .request() .query(ctCurrentVersionQuery(dbName)) .then((result) => result.recordset[0]) .then((row) => row["current_version"]); } /** * @reference https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/work-with-change-tracking-sql-server?view=sql-server-ver15#about-the-change-tracking-functions */ export function ctCurrentVersionQuery(dbName) { let query = `SELECT CHANGE_TRACKING_CURRENT_VERSION() AS current_version`; if (dbName) { query = `USE [${dbName}]; `.concat(query); } return query; } //# sourceMappingURL=change-tracking-current-version.js.map