- Add provider contract (src/providers/provider.js): query() -> {rows,
rowsAffected, insertId}, callback transaction(fn), exec() for stored
procs, initialize/purge lifecycle
- Add MssqlProvider (src/providers/mssql/index.js) wrapping an mssql
ConnectionPool with normalized results, tx commit/rollback and
constraint-error classifiers (unique 2627/2601, FK 547)
- LibDashStore constructor now takes a provider instead of a pool
(breaking); adds LibDashStore.create() async factory; keeps pool as
transitional bridge until store modules are converted (see TODO.md)
- Move MSSQL-specific code into the provider: src/sql/* ->
src/providers/mssql/queries/*, src/schema.js ->
src/providers/mssql/schema.js, purge SQL -> purgeSql.js
- Update scripts, generate-schema-graph.js and package.json exports
(./providers/mssql, ./providers/provider)
- Add TODO.md with the remaining provider/SQLite migration plan
No SQL or behavioral changes.
25 lines
710 B
JavaScript
25 lines
710 B
JavaScript
import { ADD } from '../../providers/mssql/queries/companyuser.js';
|
|
|
|
export default function add(pool) {
|
|
/**
|
|
* Adds a company user linking a company to a Google auth account.
|
|
*
|
|
* @param {number} companyId - The id of the company.
|
|
* @param {number} googleAuthId - The id of the Google auth account.
|
|
* @returns {Promise<number>} The id of the created company user link.
|
|
*
|
|
* @example
|
|
* const id = await store.companyuser.add(1, 42);
|
|
* // => 7
|
|
*/
|
|
return async (companyId, googleAuthId) => {
|
|
const result = await pool
|
|
.request()
|
|
.input('companyId', companyId)
|
|
.input('googleAuthId', googleAuthId)
|
|
.query(ADD);
|
|
|
|
return result.recordset[0].id;
|
|
};
|
|
}
|