kysely-mapper
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -5,5 +5,7 @@ export * from './mappers/table-mapper'; | ||
export * from './mappers/UniformTableMapper'; | ||
export * from './queries/paramed-count-query'; | ||
export * from './queries/paramed-row-query'; | ||
export * from './queries/delete-query'; | ||
export * from './queries/insert-query'; | ||
export * from './queries/select-query'; | ||
export * from './queries/update-query'; | ||
export * from './lib/query-filter'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -21,5 +21,7 @@ "use strict"; | ||
__exportStar(require("./mappers/UniformTableMapper"), exports); | ||
__exportStar(require("./queries/paramed-count-query"), exports); | ||
__exportStar(require("./queries/paramed-row-query"), exports); | ||
__exportStar(require("./queries/delete-query"), exports); | ||
__exportStar(require("./queries/insert-query"), exports); | ||
__exportStar(require("./queries/select-query"), exports); | ||
__exportStar(require("./queries/update-query"), exports); | ||
__exportStar(require("./lib/query-filter"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -69,6 +69,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const updates = yield this.update(this.filterForKey(key)).getReturns(obj); | ||
if (updates !== undefined) { | ||
return updates.length == 0 ? null : updates[0]; | ||
} | ||
return yield this.update(this.filterForKey(key)).getOne(obj); | ||
}); | ||
@@ -75,0 +72,0 @@ } |
@@ -28,6 +28,7 @@ import { DeleteQueryBuilder, DeleteResult, Kysely } from 'kysely'; | ||
/** | ||
* Runs the query, returning nothing. | ||
* Runs the query, deleting the indicated rows, returning nothing. | ||
* @returns `true` if any rows were deleted, `false` otherwise. | ||
*/ | ||
run(): Promise<void>; | ||
run(): Promise<boolean>; | ||
} | ||
//# sourceMappingURL=delete-query.d.ts.map |
@@ -47,7 +47,9 @@ "use strict"; | ||
/** | ||
* Runs the query, returning nothing. | ||
* Runs the query, deleting the indicated rows, returning nothing. | ||
* @returns `true` if any rows were deleted, `false` otherwise. | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.qb.execute(); | ||
const results = yield this.qb.executeTakeFirst(); | ||
return results.numDeletedRows !== BigInt(0); | ||
}); | ||
@@ -54,0 +56,0 @@ } |
@@ -27,18 +27,28 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selectable, Insertable } from 'kysely'; | ||
/** | ||
* Inserts the provided object or objects into the table as rows, first | ||
* transforming the objects into rows via `insertTransform` (if defined). | ||
* For each row inserted, retrieves the columns specified in `returnColumns`, | ||
* which are returned unless `insertReturnTransform` transforms them | ||
* into `ReturnedObject`. If `returnColumns` is empty, returns nothing. | ||
* @returns Returns a `ReturnedObject` for each inserted object. Will | ||
* be an array when `objOrObjs` is an array, will be a single object | ||
* otherwise. Returns nothing (void) if `returnColumns` is empty. | ||
* Inserts the provided objects into the table as rows, first transforming | ||
* them into rows via `insertTransform` (if defined). For each row inserted, | ||
* retrieves the columns specified in `returnColumns`, returning them to | ||
* the caller as an object, unless `insertReturnTransform` transforms them | ||
* into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns an array containing one | ||
* `ReturnedObject` for each inserted object; otherwise returns `undefined`. | ||
*/ | ||
getReturns(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>; | ||
getReturns(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
/** | ||
* Inserts rows into the table without returning any columns. | ||
* Inserts the provided object into the table as a row, first transforming | ||
* it into rows via `insertTransform` (if defined). Retrieves the columns | ||
* specified in `returnColumns` (if any), returning them to the caller as | ||
* an objectunless `insertReturnTransform` transforms them into a | ||
* `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns a `ReturnedObject`; | ||
* otherwise returns `undefined`. | ||
*/ | ||
run(objOrObjs: InsertedObject | InsertedObject[]): Promise<void>; | ||
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>; | ||
/** | ||
* Runs the query, inserting rows into the table without returning any columns. | ||
* @param objOrObjs The object or objects to be inserted. | ||
* @returns Returns `true`; throws an exception on error. | ||
*/ | ||
run(objOrObjs: InsertedObject | InsertedObject[]): Promise<boolean>; | ||
/** | ||
* Modifies the underlying Kysely query builder. | ||
@@ -45,0 +55,0 @@ * @param factory A function that takes the current query builder and |
@@ -51,25 +51,36 @@ "use strict"; | ||
} | ||
getReturns(objOrObjs) { | ||
getAll(objs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadInsertedObjects(this.qb, objOrObjs).execute(); | ||
yield this.loadInsertedObjects(this.qb, objs).execute(); | ||
return; | ||
} | ||
else { | ||
const returns = yield this.loadInsertedObjects(this.getReturningQB(), objOrObjs).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from insert expecting returned columns'); | ||
} | ||
if (Array.isArray(objOrObjs)) { | ||
return this.insertReturnTransform === undefined | ||
? returns | ||
: returns.map((row, i) => this.insertReturnTransform(objOrObjs[i], row)); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? returns[0] | ||
: this.insertReturnTransform(objOrObjs, returns[0]); | ||
const returns = yield this.loadInsertedObjects(this.getReturningQB(), objs).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from insert expecting returned columns'); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? returns | ||
: returns.map((row, i) => this.insertReturnTransform(objs[i], row)); | ||
}); | ||
} | ||
getOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadInsertedObjects(this.qb, obj).execute(); | ||
return; | ||
} | ||
const result = yield this.loadInsertedObjects(this.getReturningQB(), obj).executeTakeFirst(); | ||
if (result === undefined) { | ||
throw Error('No row returned from insert expecting returned columns'); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? result | ||
: this.insertReturnTransform(obj, result); | ||
}); | ||
} | ||
/** | ||
* Inserts rows into the table without returning any columns. | ||
* Runs the query, inserting rows into the table without returning any columns. | ||
* @param objOrObjs The object or objects to be inserted. | ||
* @returns Returns `true`; throws an exception on error. | ||
*/ | ||
@@ -79,2 +90,3 @@ run(objOrObjs) { | ||
yield this.loadInsertedObjects(this.qb, objOrObjs).execute(); | ||
return true; | ||
}); | ||
@@ -81,0 +93,0 @@ } |
@@ -20,3 +20,3 @@ import { Compilable, Kysely } from 'kysely'; | ||
*/ | ||
getMany<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
getAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
/** | ||
@@ -23,0 +23,0 @@ * Executes the query with all parameters replaced, returning the first |
@@ -45,3 +45,3 @@ "use strict"; | ||
*/ | ||
getMany(db, params) { | ||
getAll(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -48,0 +48,0 @@ const results = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").execute(db, params); |
@@ -22,3 +22,3 @@ import { Kysely, SelectQueryBuilder } from 'kysely'; | ||
*/ | ||
getMany(): Promise<SelectedObject[]>; | ||
getAll(): Promise<SelectedObject[]>; | ||
/** | ||
@@ -25,0 +25,0 @@ * Retrieves a single row from the table, using `selectTransform` |
@@ -33,3 +33,3 @@ "use strict"; | ||
*/ | ||
getMany() { | ||
getAll() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -36,0 +36,0 @@ const results = yield this.qb.execute(); |
@@ -36,14 +36,27 @@ import { Kysely, Selectable, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely'; | ||
/** | ||
* Runs the query, updating rows. For each row updated, retrieves the | ||
* columns specified in the `returnColumns` option, which are returned | ||
* unless `updateReturnTransform` transforms them into `ReturnedObject`. | ||
* If `returnColumns` is empty, returns nothing. | ||
* @returns Returns an array of `ReturnedObject` objects, one for each | ||
* updated row. | ||
* Runs the query, updating rows with the values in the provided object. | ||
* For each row updated, retrieves the columns specified in `returnColumns`, | ||
* returning them as an object, unless `updateReturnTransform` transforms | ||
* them into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns an array containing one | ||
* `ReturnedObject` for each updated object; otherwise returns `undefined`. | ||
*/ | ||
getReturns(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
getAll(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
/** | ||
* Runs the query, updating rows with the values in the provided object. | ||
* For the first updated row, retrieves the columns given in `returnColumns`, | ||
* returning them as an object, unless `updateReturnTransform` transforms | ||
* them into a `ReturnedObject`. If `returnColumns` is empty, returns | ||
* `undefined`. | ||
* @returns If `returnColumns` is empty, returned `undefined`. Otherwise, | ||
* returns a `ReturnedObject` if at least one row was updated, or `null` if | ||
* no rows were updated. | ||
*/ | ||
getOne(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject | null>; | ||
/** | ||
* Runs the query, updating rows, without returning any columns. | ||
* @param obj The object which which to update the rows. | ||
* @returns `true` if any rows were updated, `false` otherwise. | ||
*/ | ||
run(obj: UpdaterObject): Promise<void>; | ||
run(obj: UpdaterObject): Promise<boolean>; | ||
/** | ||
@@ -50,0 +63,0 @@ * Modifies the underlying Kysely query builder. |
@@ -64,24 +64,44 @@ "use strict"; | ||
} | ||
getReturns(obj) { | ||
getAll(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
return; | ||
} | ||
else { | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns | ||
: returns.map((row) => this.updateReturnTransform(obj, row)); | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns | ||
: returns.map((row) => this.updateReturnTransform(obj, row)); | ||
}); | ||
} | ||
getOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
return; | ||
} | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
if (returns.length === 0) { | ||
return null; | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns[0] | ||
: this.updateReturnTransform(obj, returns[0]); | ||
}); | ||
} | ||
/** | ||
* Runs the query, updating rows, without returning any columns. | ||
* @param obj The object which which to update the rows. | ||
* @returns `true` if any rows were updated, `false` otherwise. | ||
*/ | ||
run(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
const results = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst(); | ||
return results.numUpdatedRows !== BigInt(0); | ||
}); | ||
@@ -88,0 +108,0 @@ } |
@@ -54,4 +54,4 @@ "use strict"; | ||
// Add users | ||
const id0 = (yield explicitKeyedMapper.insert().getReturns(test_objects_1.USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
const id0 = (yield explicitKeyedMapper.insert().getOne(test_objects_1.USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
// Update a user without returning columns | ||
@@ -78,3 +78,3 @@ const NEW_EMAIL = 'new@baz.com'; | ||
const defaultKeyMapper = new KeyedTableMapper_1.KeyedTableMapper(db, 'users'); | ||
const id1 = (yield defaultKeyMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
const id1 = (yield defaultKeyMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
const NEW_EMAIL1 = 'new1@baz.com'; | ||
@@ -101,3 +101,3 @@ const updated1 = yield defaultKeyMapper.updateByKey([id1], { | ||
const defaultKeyMapper = new KeyedTableMapper_1.KeyedTableMapper(db, 'users', keyColumns); | ||
const id1 = (yield defaultKeyMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
const id1 = (yield defaultKeyMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
const NEW_EMAIL1 = 'new1@baz.com'; | ||
@@ -121,3 +121,3 @@ const updated1 = yield defaultKeyMapper.updateByKey([id1], { | ||
it('updates returning expected columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
const NEW_EMAIL = 'new@baz.com'; | ||
@@ -132,4 +132,4 @@ const updated = yield explicitKeyedMapper.updateByKey([id1], { | ||
const defaultIdMapper = new KeyedTableMapper_1.KeyedTableMapper(db, 'users'); | ||
yield defaultIdMapper.insert().getReturns(test_objects_1.USERS[0]); | ||
const id1 = (yield defaultIdMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
yield defaultIdMapper.insert().run(test_objects_1.USERS[0]); | ||
const id1 = (yield defaultIdMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
const readUser1 = yield explicitKeyedMapper.selectByKey([id1]); | ||
@@ -142,3 +142,3 @@ expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.handle).toEqual(test_objects_1.USERS[1].handle); | ||
}); | ||
const insertReturn1 = yield idAndHandleMapper.insert().getReturns(test_objects_1.USERS[0]); | ||
const insertReturn1 = yield idAndHandleMapper.insert().getOne(test_objects_1.USERS[0]); | ||
expect(insertReturn1).toEqual({ | ||
@@ -148,3 +148,3 @@ id: 1, | ||
}); | ||
const insertReturn2 = yield idAndHandleMapper.insert().getReturns(test_objects_1.USERS[1]); | ||
const insertReturn2 = yield idAndHandleMapper.insert().getOne(test_objects_1.USERS[1]); | ||
expect(insertReturn2).toEqual({ | ||
@@ -159,3 +159,3 @@ id: 2, | ||
}); | ||
const insertReturn1 = yield allColumnsMapper.insert().getReturns(test_objects_1.USERS[0]); | ||
const insertReturn1 = yield allColumnsMapper.insert().getOne(test_objects_1.USERS[0]); | ||
expect(insertReturn1).toEqual({ | ||
@@ -167,3 +167,3 @@ id: 1, | ||
}); | ||
const insertReturn2 = yield allColumnsMapper.insert().getReturns(test_objects_1.USERS[1]); | ||
const insertReturn2 = yield allColumnsMapper.insert().getOne(test_objects_1.USERS[1]); | ||
expect(insertReturn2).toEqual({ | ||
@@ -180,3 +180,3 @@ id: 2, | ||
.insert() | ||
.getReturns(test_objects_1.insertedUser1); | ||
.getOne(test_objects_1.insertedUser1); | ||
expect(insertReturn1).toEqual(test_types_1.ReturnedUser.create(1, test_objects_1.insertedUser1)); | ||
@@ -199,3 +199,3 @@ const readUser1 = yield testTransformMapper.selectByKey([1]); | ||
}); | ||
const insertReturn1 = yield noReturnMapper.insert().getReturns(test_objects_1.USERS[0]); | ||
const insertReturn1 = yield noReturnMapper.insert().getOne(test_objects_1.USERS[0]); | ||
expect(insertReturn1).toBeUndefined(); | ||
@@ -215,4 +215,4 @@ const update1 = yield noReturnMapper.updateByKey([1], { | ||
// Add users | ||
const id0 = (yield explicitKeyedMapper.insert().getReturns(test_objects_1.USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(test_objects_1.USERS[1])).id; | ||
const id0 = (yield explicitKeyedMapper.insert().getOne(test_objects_1.USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(test_objects_1.USERS[1])).id; | ||
// Update a user without returning columns | ||
@@ -254,3 +254,3 @@ const NEW_EMAIL1 = 'new1@baz.com'; | ||
// Add users | ||
const id0 = (yield multiKeyMapper.insert().getReturns({ | ||
const id0 = (yield multiKeyMapper.insert().getOne({ | ||
name: 'Jon', | ||
@@ -260,3 +260,3 @@ handle: 'jon', | ||
})).id; | ||
const id1 = (yield multiKeyMapper.insert().getReturns({ | ||
const id1 = (yield multiKeyMapper.insert().getOne({ | ||
name: 'Jon', | ||
@@ -266,3 +266,3 @@ handle: 'jonny', | ||
})).id; | ||
yield multiKeyMapper.insert().getReturns({ | ||
yield multiKeyMapper.insert().run({ | ||
name: 'John', | ||
@@ -269,0 +269,0 @@ handle: 'jonny', |
@@ -26,2 +26,8 @@ "use strict"; | ||
describe('deleting rows via TableMapper', () => { | ||
it("doesn't delete anything if no rows match", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const count = yield userMapper.delete({ name: test_objects_1.USERS[0].name }).getCount(); | ||
expect(count).toEqual(0); | ||
const success = yield userMapper.delete({ name: test_objects_1.USERS[0].name }).run(); | ||
expect(success).toEqual(false); | ||
})); | ||
it('deletes rows without returning a count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -32,5 +38,5 @@ const testMapper = new table_mapper_1.TableMapper(db, 'users', { | ||
yield testMapper.insert().run(test_objects_1.USERS); | ||
const result = yield testMapper.delete({ name: test_objects_1.USERS[0].name }).run(); | ||
expect(result).toBeUndefined(); | ||
const users = yield testMapper.select().getMany(); | ||
const success = yield testMapper.delete({ name: test_objects_1.USERS[0].name }).run(); | ||
expect(success).toBe(true); | ||
const users = yield testMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -50,3 +56,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count2).toEqual(BigInt(2)); | ||
const users = yield defaultMapper.select().getMany(); | ||
const users = yield defaultMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -69,3 +75,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count2).toEqual(2); | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -76,6 +82,11 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
const count = yield userMapper.delete().getCount(); | ||
expect(count).toEqual(3); | ||
const users = yield userMapper.select().getMany(); | ||
expect(users.length).toEqual(0); | ||
const count1 = yield userMapper.delete().getCount(); | ||
expect(count1).toEqual(3); | ||
const users1 = yield userMapper.select().getAll(); | ||
expect(users1.length).toEqual(0); | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
const success = yield userMapper.delete().run(); | ||
expect(success).toBe(true); | ||
const users2 = yield userMapper.select().getAll(); | ||
expect(users2.length).toEqual(0); | ||
})); | ||
@@ -112,3 +123,3 @@ it('deletes rows specified via compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
expect(count2).toEqual(1); | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -131,3 +142,3 @@ })); | ||
// expect(count2).toEqual(2); | ||
// const users = await userMapper.select().getMany(); | ||
// const users = await userMapper.select().getAll(); | ||
// expect(users.length).toEqual(1); | ||
@@ -139,3 +150,3 @@ // expect(users[0].handle).toEqual(USERS[1].handle); | ||
// expect(count3).toEqual(1); | ||
// const users2 = await userMapper.select().getMany(); | ||
// const users2 = await userMapper.select().getAll(); | ||
// expect(users2.length).toEqual(0); | ||
@@ -142,0 +153,0 @@ // ignore('parameterization type errors', () => { |
@@ -67,5 +67,5 @@ "use strict"; | ||
it('inserts multiple via run() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().run(test_objects_1.USERS); | ||
expect(result).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const success = yield userMapperReturningDefault.insert().run(test_objects_1.USERS); | ||
expect(success).toBe(true); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -82,6 +82,6 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
})); | ||
it('inserts multiple via getResult() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().getReturns(test_objects_1.USERS); | ||
expect(result).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
it('inserts multiple via getAll() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getAll(test_objects_1.USERS); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -93,11 +93,22 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
// @ts-expect-error - can't access columns when returning nothing | ||
result.id; | ||
results.id; | ||
// @ts-expect-error - can't access columns when returning nothing | ||
result[0].id; | ||
results[0].id; | ||
}); | ||
})); | ||
it('inserts multiple via getOne() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getOne(test_objects_1.USERS[0]); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(1); | ||
expect(readUsers[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
(0, test_utils_1.ignore)("can't access columns when returning nothing", () => { | ||
// @ts-expect-error - can't access columns when returning nothing | ||
results.id; | ||
// @ts-expect-error - can't access columns when returning nothing | ||
results[0].id; | ||
}); | ||
})); | ||
it('inserts multiple returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
expect(insertReturns.length).toEqual(3); | ||
@@ -108,3 +119,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
} | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -119,3 +130,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
.insert() | ||
.getReturns([post0, post1, post2]); | ||
.getAll([post0, post1, post2]); | ||
expect(updaterPosts.length).toEqual(3); | ||
@@ -131,5 +142,5 @@ for (let i = 0; i < updaterPosts.length; i++) { | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
.getAll(test_objects_1.USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -143,5 +154,5 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
.getAll(test_objects_1.USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -153,5 +164,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
it('inserts multiple configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningAll | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningAll.insert().getAll(test_objects_1.USERS); | ||
for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
@@ -164,11 +173,11 @@ expect(insertReturns[i].id).toBeGreaterThan(0); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns([{}]); | ||
userMapperReturningAll.insert().getAll([{}]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run([{}]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns([{ email: 'xyz@pdq.xyz' }]); | ||
userMapperReturningAll.insert().getAll([{ email: 'xyz@pdq.xyz' }]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run([{ email: 'xyz@pdq.xyz' }]); | ||
// @ts-expect-error - only configured columns are returned | ||
(yield userMapperReturningID.insert().getReturns([test_objects_1.USERS[0]]))[0].handle; | ||
(yield userMapperReturningID.insert().getAll([test_objects_1.USERS[0]]))[0].handle; | ||
// @ts-expect-error - only configured columns are returned | ||
@@ -180,4 +189,4 @@ (yield userMapperReturningID.insert().run([test_objects_1.USERS[0]]))[0].handle; | ||
it('inserts one returning no columns by default', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().run(test_objects_1.USERS[0]); | ||
expect(result).toBeUndefined(); | ||
const success = yield userMapperReturningDefault.insert().run(test_objects_1.USERS[0]); | ||
expect(success).toBe(true); | ||
const readUser0 = yield userMapperReturningAll | ||
@@ -189,4 +198,4 @@ .select(['email', '=', test_objects_1.USERS[0].email]) | ||
it('inserts one explicitly returning no columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningNothing.insert().run(test_objects_1.USERS[0]); | ||
expect(result).toBeUndefined(); | ||
const success = yield userMapperReturningNothing.insert().run(test_objects_1.USERS[0]); | ||
expect(success).toBe(true); | ||
const readUser0 = yield userMapperReturningAll | ||
@@ -198,5 +207,3 @@ .select(['email', '=', test_objects_1.USERS[0].email]) | ||
it('inserts one returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(test_objects_1.USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -211,3 +218,3 @@ expect(Object.keys(insertReturn).length).toEqual(1); | ||
.insert() | ||
.getReturns(post0); | ||
.getOne(post0); | ||
expect(updaterPost.id).toBeGreaterThan(0); | ||
@@ -225,5 +232,3 @@ expect(updaterPost.title).toEqual(test_objects_1.POSTS[0].title); | ||
it('inserts one configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningAll | ||
.insert() | ||
.getReturns(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningAll.insert().getOne(test_objects_1.USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -235,11 +240,11 @@ const expectedUser = Object.assign({}, test_objects_1.USERS[0], { id: insertReturn.id }); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns({}); | ||
userMapperReturningAll.insert().getOne({}); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run({}); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns({ email: 'xyz@pdq.xyz' }); | ||
userMapperReturningAll.insert().getOne({ email: 'xyz@pdq.xyz' }); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run({ email: 'xyz@pdq.xyz' }); | ||
// @ts-expect-error - only requested columns are returned | ||
(yield userMapperReturningID.insert().getReturns(test_objects_1.USERS[0])).name; | ||
(yield userMapperReturningID.insert().getOne(test_objects_1.USERS[0])).name; | ||
// @ts-expect-error - only requested columns are returned | ||
@@ -267,3 +272,3 @@ (yield userMapperReturningDefault.insert().run(test_objects_1.USERS[0])).name; | ||
.insert() | ||
.getReturns(test_objects_1.insertedUser1); | ||
.getOne(test_objects_1.insertedUser1); | ||
const readUser1 = yield insertTransformMapper | ||
@@ -275,8 +280,6 @@ .select({ | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.name).toEqual(`${test_objects_1.insertedUser1.firstName} ${test_objects_1.insertedUser1.lastName}`); | ||
yield insertTransformMapper | ||
.insert() | ||
.getReturns([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
yield insertTransformMapper.insert().getAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
const readUsers = yield insertTransformMapper | ||
.select(['id', '>', insertReturn.id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -299,7 +302,7 @@ expect(readUsers[0].name).toEqual(`${test_objects_1.insertedUser2.firstName} ${test_objects_1.insertedUser2.lastName}`); | ||
.insert() | ||
.getReturns(test_objects_1.userRow1); | ||
.getOne(test_objects_1.userRow1); | ||
expect(insertReturn).toEqual(test_objects_1.insertReturnedUser1); | ||
const insertReturns = yield insertReturnTransformMapper | ||
.insert() | ||
.getReturns([test_objects_1.userRow2, test_objects_1.userRow3]); | ||
.getAll([test_objects_1.userRow2, test_objects_1.userRow3]); | ||
expect(insertReturns).toEqual([test_objects_1.insertReturnedUser2, test_objects_1.insertReturnedUser3]); | ||
@@ -325,7 +328,7 @@ })); | ||
.insert() | ||
.getReturns(test_objects_1.insertedUser1); | ||
.getOne(test_objects_1.insertedUser1); | ||
expect(insertReturn).toEqual(test_objects_1.insertReturnedUser1); | ||
const insertReturns = yield insertAndReturnTransformMapper | ||
.insert() | ||
.getReturns([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
.getAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
expect(insertReturns).toEqual([test_objects_1.insertReturnedUser2, test_objects_1.insertReturnedUser3]); | ||
@@ -336,7 +339,7 @@ })); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getReturns(test_objects_1.USERS[0]); | ||
yield insertTransformMapper.insert().getOne(test_objects_1.USERS[0]); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().run(test_objects_1.USERS[0]); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getReturns(test_objects_1.selectedUser1); | ||
yield insertTransformMapper.insert().getOne(test_objects_1.selectedUser1); | ||
// @ts-expect-error - requires InsertedObject as input | ||
@@ -343,0 +346,0 @@ yield insertTransformMapper.insert().run(test_objects_1.selectedUser1); |
@@ -41,3 +41,3 @@ "use strict"; | ||
// ); | ||
// const users = await parameterization.getMany(db, { | ||
// const users = await parameterization.getAll(db, { | ||
// name: USERS[0].name, | ||
@@ -58,3 +58,3 @@ // }); | ||
// // @ts-expect-error - errors on invalid parameter names | ||
// parameterization.getMany(db, { notThere: 'foo' }); | ||
// parameterization.getAll(db, { notThere: 'foo' }); | ||
// // @ts-expect-error - errors on invalid column names | ||
@@ -71,3 +71,3 @@ // users[0].notThere; | ||
.modify((qb) => qb.where('name', '=', test_objects_1.USERS[0].name).orderBy('handle', 'desc')) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -87,3 +87,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[2].handle); | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getMany(); | ||
.getAll(); | ||
expect(users).toEqual([ | ||
@@ -132,6 +132,6 @@ Object.assign(Object.assign({}, test_objects_1.USERS[2]), { id: 3 }), | ||
}); | ||
describe('select() getMany()', () => { | ||
describe('select() getAll()', () => { | ||
it('selects nothing when nothing matches filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
const users = yield userMapper.select({ name: 'Not There' }).getMany(); | ||
const users = yield userMapper.select({ name: 'Not There' }).getAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -142,3 +142,3 @@ })); | ||
// Test selecting all | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(test_objects_1.USERS.length); | ||
@@ -155,3 +155,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -165,3 +165,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -173,3 +173,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select(['name', '=', test_objects_1.USERS[0].name]).getMany(); | ||
let users = yield userMapper.select(['name', '=', test_objects_1.USERS[0].name]).getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -179,3 +179,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getMany(); | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -187,3 +187,3 @@ })); | ||
.select((0, kysely_1.sql) `name != ${test_objects_1.USERS[0].name}`) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -198,3 +198,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -208,3 +208,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -216,3 +216,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select(['name', '=', test_objects_1.USERS[0].name]).getMany(); | ||
let users = yield userMapper.select(['name', '=', test_objects_1.USERS[0].name]).getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -222,7 +222,7 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getMany(); | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getAll(); | ||
expect(users.length).toEqual(0); | ||
})); | ||
it('selects many returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getReturns(test_objects_1.USERS); | ||
const ids = yield userMapper.insert().getAll(test_objects_1.USERS); | ||
const mapper = new table_mapper_1.TableMapper(db, 'users', { | ||
@@ -232,4 +232,4 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getMany())[0].h; | ||
const users = yield mapper.select({ name: test_objects_1.USERS[0].name }).getMany(); | ||
(yield mapper.select().getAll())[0].h; | ||
const users = yield mapper.select({ name: test_objects_1.USERS[0].name }).getAll(); | ||
expect(users).toEqual([ | ||
@@ -249,20 +249,20 @@ { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getMany())[0].name; | ||
(yield mapper.select().getAll())[0].name; | ||
})); | ||
})); | ||
(0, test_utils_1.ignore)('detects select() getMany() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, test_utils_1.ignore)('detects select() getAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select().getMany())[0].notThere; | ||
(yield userMapper.select().getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getMany())[0].notThere; | ||
(yield userMapper.select({}).getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
// prettier-ignore | ||
(yield userMapper.select({ name: "Sue" }).getMany())[0].notThere; | ||
(yield userMapper.select({ name: "Sue" }).getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select(["name", "=", "Sue"]).getMany())[0].notThere; | ||
(yield userMapper.select(["name", "=", "Sue"]).getAll())[0].notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getMany() | ||
.getAll() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -273,3 +273,3 @@ )[0].notThere; | ||
.select((0, kysely_1.sql) `name = 'Sue'`) | ||
.getMany() | ||
.getAll() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -316,3 +316,3 @@ )[0].notThere; | ||
it('selects the first row with a compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const userIDs = yield userMapper.insert().getReturns(test_objects_1.USERS); | ||
const userIDs = yield userMapper.insert().getAll(test_objects_1.USERS); | ||
const user = yield userMapper | ||
@@ -345,3 +345,3 @@ .select(({ and, cmpr }) => and([cmpr('name', '=', test_objects_1.USERS[0].name), cmpr('id', '>', userIDs[0].id)])) | ||
it('selects one returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getReturns(test_objects_1.USERS); | ||
const ids = yield userMapper.insert().getAll(test_objects_1.USERS); | ||
const mapper = new table_mapper_1.TableMapper(db, 'users', { | ||
@@ -356,3 +356,3 @@ selectedColumns: ['id', 'handle as h'], | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getMany())[0].name; | ||
(yield mapper.select().getAll())[0].name; | ||
})); | ||
@@ -359,0 +359,0 @@ })); |
@@ -36,4 +36,8 @@ "use strict"; | ||
describe('updating rows via TableMapper', () => { | ||
it('updates returning zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('updates nothing returning zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const success = yield userMapperReturningAll | ||
.update({ id: 1 }) | ||
.run(updateValues); | ||
expect(success).toBe(false); | ||
const updateCount = yield userMapperReturningAll | ||
@@ -45,10 +49,12 @@ .update({ id: 1 }) | ||
.update({ id: 1 }) | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
expect(updates.length).toEqual(0); | ||
const update = yield userMapperReturningID | ||
.update({ id: 1 }) | ||
.getOne(updateValues); | ||
expect(update).toBeNull(); | ||
})); | ||
it('updates returning non-zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('updates something returning non-zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const insertReturn0 = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS[0]); | ||
const insertReturn0 = yield userMapperReturningID.insert().getOne(test_objects_1.USERS[0]); | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[1]); | ||
@@ -60,6 +66,6 @@ yield userMapperReturningID.insert().run(test_objects_1.USERS[2]); | ||
expect(updateCount1).toEqual(1); | ||
const readUser = yield userMapperReturningID | ||
const readUser1 = yield userMapperReturningID | ||
.select(['id', '=', insertReturn0.id]) | ||
.getOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.email).toEqual(updateValues.email); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.email).toEqual(updateValues.email); | ||
const updateCount2 = yield userMapperReturningAll | ||
@@ -71,17 +77,32 @@ .update({ name: 'Sue' }) | ||
.select(['name', '=', 'Sue']) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
expect(readUsers[0].email).toEqual(updateValues.email); | ||
expect(readUsers[1].email).toEqual(updateValues.email); | ||
// prettier-ignore | ||
const updates = yield userMapperReturningID.update().getAll({ | ||
name: 'Every User 1', | ||
}); | ||
expect(updates).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]); | ||
const update = yield userMapperReturningID | ||
.update({ id: readUsers[0].id }) | ||
.getOne({ | ||
name: 'Every User 2', | ||
}); | ||
expect(update).toEqual({ id: 1 }); | ||
const readUser2 = yield userMapperReturningID | ||
.select(['id', '=', 1]) | ||
.getOne(); | ||
expect(readUser2 === null || readUser2 === void 0 ? void 0 : readUser2.name).toEqual('Every User 2'); | ||
const updateCount = yield userMapperReturningID.update().getCount({ | ||
name: "Every User", | ||
name: 'Every User 3', | ||
}); | ||
expect(updateCount).toEqual(3); | ||
const success = yield userMapperReturningID.update().run({ | ||
name: 'Every User 4', | ||
}); | ||
expect(success).toBe(true); | ||
})); | ||
it('updates returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS[1]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(test_objects_1.USERS[1]); | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[2]); | ||
@@ -92,3 +113,3 @@ // Verify that update performs the correct change on the correct row. | ||
.update({ id: insertReturn.id }) | ||
.getReturns(updateValues1); | ||
.getAll(updateValues1); | ||
expect(updateReturns1).toEqual([{ id: insertReturn.id }]); | ||
@@ -103,3 +124,3 @@ let readUser = yield userMapperReturningID | ||
.update({ email: updateValues1.email }) | ||
.getReturns(updateValues2); | ||
.getAll(updateValues2); | ||
expect(updateReturns2).toEqual([ | ||
@@ -119,3 +140,3 @@ { | ||
.update({ name: 'Sue' }) | ||
.getReturns(updateValues3); | ||
.getAll(updateValues3); | ||
expect(updateReturns3.length).toEqual(3); | ||
@@ -127,3 +148,3 @@ expect(updateReturns3[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
.select(['name', '=', updateValues3.name]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -135,3 +156,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getReturns({ email: 'new.email@xyz.pdq' }); | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -142,3 +163,3 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -150,3 +171,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getReturns({ email: 'new.email@xyz.pdq' }); | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -157,13 +178,11 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
})); | ||
it('updates configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningAll | ||
.update({ name: 'Sue' }) | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
const expectedUsers = [ | ||
@@ -176,9 +195,7 @@ Object.assign({}, test_objects_1.USERS[0], updateValues, { id: insertReturns[0].id }), | ||
it('updates all rows when no filter is given', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningIDAndHandle | ||
.update() | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
const expectedUsers = test_objects_1.USERS.map((user, i) => { | ||
@@ -188,3 +205,3 @@ return { id: insertReturns[i].id, handle: user.handle }; | ||
expect(updateReturns).toEqual(expectedUsers); | ||
const readUsers = yield userMapperReturningID.select().getMany(); | ||
const readUsers = yield userMapperReturningID.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -196,5 +213,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a binary operator', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -207,3 +222,3 @@ const updateCount = yield userMapperReturningAll | ||
.select(['id', '>', insertReturns[0].id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -215,5 +230,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a kysely expression', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -226,3 +239,3 @@ const updateCount = yield userMapperReturningDefault | ||
.select(['id', '>', insertReturns[0].id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -234,5 +247,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a where expression filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const updateValues1 = { email: 'foo@xyz.pdq' }; | ||
@@ -252,3 +263,3 @@ const updateCount = yield userMapperReturningAll | ||
])) | ||
.getReturns(updateValues2); | ||
.getAll(updateValues2); | ||
expect(updateReturns).toEqual([ | ||
@@ -269,9 +280,9 @@ { id: insertReturns[0].id }, | ||
{ notThere: 'xyz' }) | ||
.getReturns({ email: 'abc@def.ghi' }); | ||
.getAll({ email: 'abc@def.ghi' }); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getReturns({ | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getAll({ | ||
email: 'abc@def.ghi', | ||
}); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getReturns({ | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getAll({ | ||
email: 'abc@def.ghi', | ||
@@ -282,4 +293,4 @@ }); | ||
// @ts-expect-error - update must only have table columns | ||
.getReturns({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getReturns( | ||
.getAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getAll( | ||
// @ts-expect-error - update must only have table columns | ||
@@ -293,6 +304,6 @@ { notThere: 'xyz@pdq.xyz' }); | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getReturns(test_objects_1.USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(test_objects_1.USERS[0]))[0].name; | ||
// @ts-expect-error - only requested columns are accessible | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getReturns(test_objects_1.USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(test_objects_1.USERS[0]))[0].name; | ||
yield userMapperReturningID | ||
@@ -307,3 +318,3 @@ .update(({ or, cmpr }) => | ||
or([cmpr('notThere', '=', 'xyz'), cmpr('alsoNotThere', '=', 'Sue')])) | ||
.getReturns(test_objects_1.USERS[0]); | ||
.getAll(test_objects_1.USERS[0]); | ||
})); | ||
@@ -328,3 +339,3 @@ }); | ||
.insert() | ||
.getReturns([test_objects_1.userRow1, test_objects_1.userRow2, test_objects_1.userRow3]); | ||
.getAll([test_objects_1.userRow1, test_objects_1.userRow2, test_objects_1.userRow3]); | ||
const updaterUser1 = test_types_1.UpdaterUser.create(0, Object.assign({}, test_objects_1.userObject1, { firstName: 'Suzanne' })); | ||
@@ -336,3 +347,3 @@ const updateReturns = yield mapper | ||
])) | ||
.getReturns(updaterUser1); | ||
.getAll(updaterUser1); | ||
expect(updateReturns).toEqual([ | ||
@@ -345,3 +356,3 @@ { id: insertReturns[0].id }, | ||
.modify((qb) => qb.orderBy('id')) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers).toEqual([ | ||
@@ -371,6 +382,6 @@ Object.assign({}, test_objects_1.userRow1, { | ||
.insert() | ||
.getReturns(test_objects_1.userRow1); | ||
.getOne(test_objects_1.userRow1); | ||
const updateReturn = yield updateReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getReturns({ name: 'Suzanne Smith' }); | ||
.getAll({ name: 'Suzanne Smith' }); | ||
expect(updateReturn).toEqual([ | ||
@@ -397,6 +408,6 @@ new test_types_1.ReturnedUser(insertReturn.id, 'Suzanne', 'Smith', '(handle)', '(email)'), | ||
.insert() | ||
.getReturns(test_objects_1.userRow1); | ||
.getOne(test_objects_1.userRow1); | ||
const updateReturn = yield updateAndReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getReturns(test_types_1.UpdaterUser.create(0, test_objects_1.userObject1)); | ||
.getAll(test_types_1.UpdaterUser.create(0, test_objects_1.userObject1)); | ||
expect(updateReturn).toEqual([ | ||
@@ -403,0 +414,0 @@ new test_types_1.ReturnedUser(insertReturn.id, test_objects_1.userObject1.firstName, test_objects_1.userObject1.lastName, test_objects_1.userObject1.handle, test_objects_1.userObject1.email), |
@@ -40,3 +40,3 @@ "use strict"; | ||
const insertedUser1 = new KeyedUser(0, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email); | ||
const insertReturn1 = (yield userMapper.insert().getReturns(insertedUser1)); | ||
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1)); | ||
expect(insertReturn1).not.toBeNull(); | ||
@@ -50,3 +50,3 @@ expect(insertReturn1.id).toBeGreaterThan(0); | ||
const insertedUser2 = new KeyedUser(10, test_objects_1.USERS[1].name, test_objects_1.USERS[1].handle, test_objects_1.USERS[1].email); | ||
const insertReturn2 = (yield userMapper.insert().getReturns(insertedUser2)); | ||
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2)); | ||
expect(insertReturn2).toEqual(insertedUser2); | ||
@@ -117,3 +117,3 @@ const selectedUser2 = yield userMapper.selectByKey(insertReturn2.id); | ||
const insertedUser = new KeyedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getReturns(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
expect(insertReturn).not.toBeNull(); | ||
@@ -135,3 +135,3 @@ expect(insertReturn.serialNo).toBeGreaterThan(0); | ||
.update(['id', '=', insertReturn.serialNo]) | ||
.getReturns({ | ||
.getAll({ | ||
name: 'Foo Foo', | ||
@@ -189,3 +189,3 @@ }); | ||
const insertedUser = new KeyedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getReturns(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
expect(insertReturn).not.toBeNull(); | ||
@@ -192,0 +192,0 @@ expect(insertReturn.id).toBeGreaterThan(0); |
@@ -5,5 +5,7 @@ export * from './mappers/table-mapper'; | ||
export * from './mappers/UniformTableMapper'; | ||
export * from './queries/paramed-count-query'; | ||
export * from './queries/paramed-row-query'; | ||
export * from './queries/delete-query'; | ||
export * from './queries/insert-query'; | ||
export * from './queries/select-query'; | ||
export * from './queries/update-query'; | ||
export * from './lib/query-filter'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,5 +5,7 @@ export * from './mappers/table-mapper'; | ||
export * from './mappers/UniformTableMapper'; | ||
export * from './queries/paramed-count-query'; | ||
export * from './queries/paramed-row-query'; | ||
export * from './queries/delete-query'; | ||
export * from './queries/insert-query'; | ||
export * from './queries/select-query'; | ||
export * from './queries/update-query'; | ||
export * from './lib/query-filter'; | ||
//# sourceMappingURL=index.js.map |
@@ -66,6 +66,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const updates = yield this.update(this.filterForKey(key)).getReturns(obj); | ||
if (updates !== undefined) { | ||
return updates.length == 0 ? null : updates[0]; | ||
} | ||
return yield this.update(this.filterForKey(key)).getOne(obj); | ||
}); | ||
@@ -72,0 +69,0 @@ } |
@@ -28,6 +28,7 @@ import { DeleteQueryBuilder, DeleteResult, Kysely } from 'kysely'; | ||
/** | ||
* Runs the query, returning nothing. | ||
* Runs the query, deleting the indicated rows, returning nothing. | ||
* @returns `true` if any rows were deleted, `false` otherwise. | ||
*/ | ||
run(): Promise<void>; | ||
run(): Promise<boolean>; | ||
} | ||
//# sourceMappingURL=delete-query.d.ts.map |
@@ -44,7 +44,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Runs the query, returning nothing. | ||
* Runs the query, deleting the indicated rows, returning nothing. | ||
* @returns `true` if any rows were deleted, `false` otherwise. | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.qb.execute(); | ||
const results = yield this.qb.executeTakeFirst(); | ||
return results.numDeletedRows !== BigInt(0); | ||
}); | ||
@@ -51,0 +53,0 @@ } |
@@ -27,18 +27,28 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selectable, Insertable } from 'kysely'; | ||
/** | ||
* Inserts the provided object or objects into the table as rows, first | ||
* transforming the objects into rows via `insertTransform` (if defined). | ||
* For each row inserted, retrieves the columns specified in `returnColumns`, | ||
* which are returned unless `insertReturnTransform` transforms them | ||
* into `ReturnedObject`. If `returnColumns` is empty, returns nothing. | ||
* @returns Returns a `ReturnedObject` for each inserted object. Will | ||
* be an array when `objOrObjs` is an array, will be a single object | ||
* otherwise. Returns nothing (void) if `returnColumns` is empty. | ||
* Inserts the provided objects into the table as rows, first transforming | ||
* them into rows via `insertTransform` (if defined). For each row inserted, | ||
* retrieves the columns specified in `returnColumns`, returning them to | ||
* the caller as an object, unless `insertReturnTransform` transforms them | ||
* into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns an array containing one | ||
* `ReturnedObject` for each inserted object; otherwise returns `undefined`. | ||
*/ | ||
getReturns(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>; | ||
getReturns(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
/** | ||
* Inserts rows into the table without returning any columns. | ||
* Inserts the provided object into the table as a row, first transforming | ||
* it into rows via `insertTransform` (if defined). Retrieves the columns | ||
* specified in `returnColumns` (if any), returning them to the caller as | ||
* an objectunless `insertReturnTransform` transforms them into a | ||
* `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns a `ReturnedObject`; | ||
* otherwise returns `undefined`. | ||
*/ | ||
run(objOrObjs: InsertedObject | InsertedObject[]): Promise<void>; | ||
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>; | ||
/** | ||
* Runs the query, inserting rows into the table without returning any columns. | ||
* @param objOrObjs The object or objects to be inserted. | ||
* @returns Returns `true`; throws an exception on error. | ||
*/ | ||
run(objOrObjs: InsertedObject | InsertedObject[]): Promise<boolean>; | ||
/** | ||
* Modifies the underlying Kysely query builder. | ||
@@ -45,0 +55,0 @@ * @param factory A function that takes the current query builder and |
@@ -48,25 +48,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
getReturns(objOrObjs) { | ||
getAll(objs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadInsertedObjects(this.qb, objOrObjs).execute(); | ||
yield this.loadInsertedObjects(this.qb, objs).execute(); | ||
return; | ||
} | ||
else { | ||
const returns = yield this.loadInsertedObjects(this.getReturningQB(), objOrObjs).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from insert expecting returned columns'); | ||
} | ||
if (Array.isArray(objOrObjs)) { | ||
return this.insertReturnTransform === undefined | ||
? returns | ||
: returns.map((row, i) => this.insertReturnTransform(objOrObjs[i], row)); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? returns[0] | ||
: this.insertReturnTransform(objOrObjs, returns[0]); | ||
const returns = yield this.loadInsertedObjects(this.getReturningQB(), objs).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from insert expecting returned columns'); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? returns | ||
: returns.map((row, i) => this.insertReturnTransform(objs[i], row)); | ||
}); | ||
} | ||
getOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadInsertedObjects(this.qb, obj).execute(); | ||
return; | ||
} | ||
const result = yield this.loadInsertedObjects(this.getReturningQB(), obj).executeTakeFirst(); | ||
if (result === undefined) { | ||
throw Error('No row returned from insert expecting returned columns'); | ||
} | ||
return this.insertReturnTransform === undefined | ||
? result | ||
: this.insertReturnTransform(obj, result); | ||
}); | ||
} | ||
/** | ||
* Inserts rows into the table without returning any columns. | ||
* Runs the query, inserting rows into the table without returning any columns. | ||
* @param objOrObjs The object or objects to be inserted. | ||
* @returns Returns `true`; throws an exception on error. | ||
*/ | ||
@@ -76,2 +87,3 @@ run(objOrObjs) { | ||
yield this.loadInsertedObjects(this.qb, objOrObjs).execute(); | ||
return true; | ||
}); | ||
@@ -78,0 +90,0 @@ } |
@@ -20,3 +20,3 @@ import { Compilable, Kysely } from 'kysely'; | ||
*/ | ||
getMany<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
getAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
/** | ||
@@ -23,0 +23,0 @@ * Executes the query with all parameters replaced, returning the first |
@@ -42,3 +42,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
*/ | ||
getMany(db, params) { | ||
getAll(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -45,0 +45,0 @@ const results = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").execute(db, params); |
@@ -22,3 +22,3 @@ import { Kysely, SelectQueryBuilder } from 'kysely'; | ||
*/ | ||
getMany(): Promise<SelectedObject[]>; | ||
getAll(): Promise<SelectedObject[]>; | ||
/** | ||
@@ -25,0 +25,0 @@ * Retrieves a single row from the table, using `selectTransform` |
@@ -30,3 +30,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
*/ | ||
getMany() { | ||
getAll() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -33,0 +33,0 @@ const results = yield this.qb.execute(); |
@@ -36,14 +36,27 @@ import { Kysely, Selectable, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely'; | ||
/** | ||
* Runs the query, updating rows. For each row updated, retrieves the | ||
* columns specified in the `returnColumns` option, which are returned | ||
* unless `updateReturnTransform` transforms them into `ReturnedObject`. | ||
* If `returnColumns` is empty, returns nothing. | ||
* @returns Returns an array of `ReturnedObject` objects, one for each | ||
* updated row. | ||
* Runs the query, updating rows with the values in the provided object. | ||
* For each row updated, retrieves the columns specified in `returnColumns`, | ||
* returning them as an object, unless `updateReturnTransform` transforms | ||
* them into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`. | ||
* @returns If `returnColumns` is not empty, returns an array containing one | ||
* `ReturnedObject` for each updated object; otherwise returns `undefined`. | ||
*/ | ||
getReturns(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
getAll(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>; | ||
/** | ||
* Runs the query, updating rows with the values in the provided object. | ||
* For the first updated row, retrieves the columns given in `returnColumns`, | ||
* returning them as an object, unless `updateReturnTransform` transforms | ||
* them into a `ReturnedObject`. If `returnColumns` is empty, returns | ||
* `undefined`. | ||
* @returns If `returnColumns` is empty, returned `undefined`. Otherwise, | ||
* returns a `ReturnedObject` if at least one row was updated, or `null` if | ||
* no rows were updated. | ||
*/ | ||
getOne(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject | null>; | ||
/** | ||
* Runs the query, updating rows, without returning any columns. | ||
* @param obj The object which which to update the rows. | ||
* @returns `true` if any rows were updated, `false` otherwise. | ||
*/ | ||
run(obj: UpdaterObject): Promise<void>; | ||
run(obj: UpdaterObject): Promise<boolean>; | ||
/** | ||
@@ -50,0 +63,0 @@ * Modifies the underlying Kysely query builder. |
@@ -61,24 +61,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
getReturns(obj) { | ||
getAll(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
return; | ||
} | ||
else { | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns | ||
: returns.map((row) => this.updateReturnTransform(obj, row)); | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns | ||
: returns.map((row) => this.updateReturnTransform(obj, row)); | ||
}); | ||
} | ||
getOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.returnColumns.length === 0) { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
return; | ||
} | ||
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute(); | ||
if (returns === undefined) { | ||
throw Error('No rows returned from update expecting returned columns'); | ||
} | ||
if (returns.length === 0) { | ||
return null; | ||
} | ||
return this.updateReturnTransform === undefined | ||
? returns[0] | ||
: this.updateReturnTransform(obj, returns[0]); | ||
}); | ||
} | ||
/** | ||
* Runs the query, updating rows, without returning any columns. | ||
* @param obj The object which which to update the rows. | ||
* @returns `true` if any rows were updated, `false` otherwise. | ||
*/ | ||
run(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.loadUpdaterObject(this.qb, obj).execute(); | ||
const results = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst(); | ||
return results.numUpdatedRows !== BigInt(0); | ||
}); | ||
@@ -85,0 +105,0 @@ } |
@@ -52,4 +52,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
// Add users | ||
const id0 = (yield explicitKeyedMapper.insert().getReturns(USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(USERS[1])).id; | ||
const id0 = (yield explicitKeyedMapper.insert().getOne(USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(USERS[1])).id; | ||
// Update a user without returning columns | ||
@@ -76,3 +76,3 @@ const NEW_EMAIL = 'new@baz.com'; | ||
const defaultKeyMapper = new KeyedTableMapper(db, 'users'); | ||
const id1 = (yield defaultKeyMapper.insert().getReturns(USERS[1])).id; | ||
const id1 = (yield defaultKeyMapper.insert().getOne(USERS[1])).id; | ||
const NEW_EMAIL1 = 'new1@baz.com'; | ||
@@ -99,3 +99,3 @@ const updated1 = yield defaultKeyMapper.updateByKey([id1], { | ||
const defaultKeyMapper = new KeyedTableMapper(db, 'users', keyColumns); | ||
const id1 = (yield defaultKeyMapper.insert().getReturns(USERS[1])).id; | ||
const id1 = (yield defaultKeyMapper.insert().getOne(USERS[1])).id; | ||
const NEW_EMAIL1 = 'new1@baz.com'; | ||
@@ -119,3 +119,3 @@ const updated1 = yield defaultKeyMapper.updateByKey([id1], { | ||
it('updates returning expected columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(USERS[1])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(USERS[1])).id; | ||
const NEW_EMAIL = 'new@baz.com'; | ||
@@ -130,4 +130,4 @@ const updated = yield explicitKeyedMapper.updateByKey([id1], { | ||
const defaultIdMapper = new KeyedTableMapper(db, 'users'); | ||
yield defaultIdMapper.insert().getReturns(USERS[0]); | ||
const id1 = (yield defaultIdMapper.insert().getReturns(USERS[1])).id; | ||
yield defaultIdMapper.insert().run(USERS[0]); | ||
const id1 = (yield defaultIdMapper.insert().getOne(USERS[1])).id; | ||
const readUser1 = yield explicitKeyedMapper.selectByKey([id1]); | ||
@@ -140,3 +140,3 @@ expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.handle).toEqual(USERS[1].handle); | ||
}); | ||
const insertReturn1 = yield idAndHandleMapper.insert().getReturns(USERS[0]); | ||
const insertReturn1 = yield idAndHandleMapper.insert().getOne(USERS[0]); | ||
expect(insertReturn1).toEqual({ | ||
@@ -146,3 +146,3 @@ id: 1, | ||
}); | ||
const insertReturn2 = yield idAndHandleMapper.insert().getReturns(USERS[1]); | ||
const insertReturn2 = yield idAndHandleMapper.insert().getOne(USERS[1]); | ||
expect(insertReturn2).toEqual({ | ||
@@ -157,3 +157,3 @@ id: 2, | ||
}); | ||
const insertReturn1 = yield allColumnsMapper.insert().getReturns(USERS[0]); | ||
const insertReturn1 = yield allColumnsMapper.insert().getOne(USERS[0]); | ||
expect(insertReturn1).toEqual({ | ||
@@ -165,3 +165,3 @@ id: 1, | ||
}); | ||
const insertReturn2 = yield allColumnsMapper.insert().getReturns(USERS[1]); | ||
const insertReturn2 = yield allColumnsMapper.insert().getOne(USERS[1]); | ||
expect(insertReturn2).toEqual({ | ||
@@ -178,3 +178,3 @@ id: 2, | ||
.insert() | ||
.getReturns(insertedUser1); | ||
.getOne(insertedUser1); | ||
expect(insertReturn1).toEqual(ReturnedUser.create(1, insertedUser1)); | ||
@@ -197,3 +197,3 @@ const readUser1 = yield testTransformMapper.selectByKey([1]); | ||
}); | ||
const insertReturn1 = yield noReturnMapper.insert().getReturns(USERS[0]); | ||
const insertReturn1 = yield noReturnMapper.insert().getOne(USERS[0]); | ||
expect(insertReturn1).toBeUndefined(); | ||
@@ -213,4 +213,4 @@ const update1 = yield noReturnMapper.updateByKey([1], { | ||
// Add users | ||
const id0 = (yield explicitKeyedMapper.insert().getReturns(USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getReturns(USERS[1])).id; | ||
const id0 = (yield explicitKeyedMapper.insert().getOne(USERS[0])).id; | ||
const id1 = (yield explicitKeyedMapper.insert().getOne(USERS[1])).id; | ||
// Update a user without returning columns | ||
@@ -252,3 +252,3 @@ const NEW_EMAIL1 = 'new1@baz.com'; | ||
// Add users | ||
const id0 = (yield multiKeyMapper.insert().getReturns({ | ||
const id0 = (yield multiKeyMapper.insert().getOne({ | ||
name: 'Jon', | ||
@@ -258,3 +258,3 @@ handle: 'jon', | ||
})).id; | ||
const id1 = (yield multiKeyMapper.insert().getReturns({ | ||
const id1 = (yield multiKeyMapper.insert().getOne({ | ||
name: 'Jon', | ||
@@ -264,3 +264,3 @@ handle: 'jonny', | ||
})).id; | ||
yield multiKeyMapper.insert().getReturns({ | ||
yield multiKeyMapper.insert().run({ | ||
name: 'John', | ||
@@ -267,0 +267,0 @@ handle: 'jonny', |
@@ -24,2 +24,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
describe('deleting rows via TableMapper', () => { | ||
it("doesn't delete anything if no rows match", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const count = yield userMapper.delete({ name: USERS[0].name }).getCount(); | ||
expect(count).toEqual(0); | ||
const success = yield userMapper.delete({ name: USERS[0].name }).run(); | ||
expect(success).toEqual(false); | ||
})); | ||
it('deletes rows without returning a count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -30,5 +36,5 @@ const testMapper = new TableMapper(db, 'users', { | ||
yield testMapper.insert().run(USERS); | ||
const result = yield testMapper.delete({ name: USERS[0].name }).run(); | ||
expect(result).toBeUndefined(); | ||
const users = yield testMapper.select().getMany(); | ||
const success = yield testMapper.delete({ name: USERS[0].name }).run(); | ||
expect(success).toBe(true); | ||
const users = yield testMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -48,3 +54,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count2).toEqual(BigInt(2)); | ||
const users = yield defaultMapper.select().getMany(); | ||
const users = yield defaultMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -67,3 +73,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count2).toEqual(2); | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -74,6 +80,11 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
yield userMapper.insert().run(USERS); | ||
const count = yield userMapper.delete().getCount(); | ||
expect(count).toEqual(3); | ||
const users = yield userMapper.select().getMany(); | ||
expect(users.length).toEqual(0); | ||
const count1 = yield userMapper.delete().getCount(); | ||
expect(count1).toEqual(3); | ||
const users1 = yield userMapper.select().getAll(); | ||
expect(users1.length).toEqual(0); | ||
yield userMapper.insert().run(USERS); | ||
const success = yield userMapper.delete().run(); | ||
expect(success).toBe(true); | ||
const users2 = yield userMapper.select().getAll(); | ||
expect(users2.length).toEqual(0); | ||
})); | ||
@@ -110,3 +121,3 @@ it('deletes rows specified via compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
expect(count2).toEqual(1); | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -129,3 +140,3 @@ })); | ||
// expect(count2).toEqual(2); | ||
// const users = await userMapper.select().getMany(); | ||
// const users = await userMapper.select().getAll(); | ||
// expect(users.length).toEqual(1); | ||
@@ -137,3 +148,3 @@ // expect(users[0].handle).toEqual(USERS[1].handle); | ||
// expect(count3).toEqual(1); | ||
// const users2 = await userMapper.select().getMany(); | ||
// const users2 = await userMapper.select().getAll(); | ||
// expect(users2.length).toEqual(0); | ||
@@ -140,0 +151,0 @@ // ignore('parameterization type errors', () => { |
@@ -65,5 +65,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
it('inserts multiple via run() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().run(USERS); | ||
expect(result).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const success = yield userMapperReturningDefault.insert().run(USERS); | ||
expect(success).toBe(true); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -80,6 +80,6 @@ for (let i = 0; i < USERS.length; i++) { | ||
})); | ||
it('inserts multiple via getResult() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().getReturns(USERS); | ||
expect(result).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
it('inserts multiple via getAll() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getAll(USERS); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -91,11 +91,22 @@ for (let i = 0; i < USERS.length; i++) { | ||
// @ts-expect-error - can't access columns when returning nothing | ||
result.id; | ||
results.id; | ||
// @ts-expect-error - can't access columns when returning nothing | ||
result[0].id; | ||
results[0].id; | ||
}); | ||
})); | ||
it('inserts multiple via getOne() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getOne(USERS[0]); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(1); | ||
expect(readUsers[0].handle).toEqual(USERS[0].handle); | ||
ignore("can't access columns when returning nothing", () => { | ||
// @ts-expect-error - can't access columns when returning nothing | ||
results.id; | ||
// @ts-expect-error - can't access columns when returning nothing | ||
results[0].id; | ||
}); | ||
})); | ||
it('inserts multiple returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
expect(insertReturns.length).toEqual(3); | ||
@@ -106,3 +117,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
} | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -117,3 +128,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
.insert() | ||
.getReturns([post0, post1, post2]); | ||
.getAll([post0, post1, post2]); | ||
expect(updaterPosts.length).toEqual(3); | ||
@@ -129,5 +140,5 @@ for (let i = 0; i < updaterPosts.length; i++) { | ||
.insert() | ||
.getReturns(USERS); | ||
.getAll(USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -141,5 +152,5 @@ for (let i = 0; i < USERS.length; i++) { | ||
.insert() | ||
.getReturns(USERS); | ||
.getAll(USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getMany(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -151,5 +162,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
it('inserts multiple configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningAll | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningAll.insert().getAll(USERS); | ||
for (let i = 0; i < USERS.length; i++) { | ||
@@ -162,11 +171,11 @@ expect(insertReturns[i].id).toBeGreaterThan(0); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns([{}]); | ||
userMapperReturningAll.insert().getAll([{}]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run([{}]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns([{ email: 'xyz@pdq.xyz' }]); | ||
userMapperReturningAll.insert().getAll([{ email: 'xyz@pdq.xyz' }]); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run([{ email: 'xyz@pdq.xyz' }]); | ||
// @ts-expect-error - only configured columns are returned | ||
(yield userMapperReturningID.insert().getReturns([USERS[0]]))[0].handle; | ||
(yield userMapperReturningID.insert().getAll([USERS[0]]))[0].handle; | ||
// @ts-expect-error - only configured columns are returned | ||
@@ -178,4 +187,4 @@ (yield userMapperReturningID.insert().run([USERS[0]]))[0].handle; | ||
it('inserts one returning no columns by default', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningDefault.insert().run(USERS[0]); | ||
expect(result).toBeUndefined(); | ||
const success = yield userMapperReturningDefault.insert().run(USERS[0]); | ||
expect(success).toBe(true); | ||
const readUser0 = yield userMapperReturningAll | ||
@@ -187,4 +196,4 @@ .select(['email', '=', USERS[0].email]) | ||
it('inserts one explicitly returning no columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const result = yield userMapperReturningNothing.insert().run(USERS[0]); | ||
expect(result).toBeUndefined(); | ||
const success = yield userMapperReturningNothing.insert().run(USERS[0]); | ||
expect(success).toBe(true); | ||
const readUser0 = yield userMapperReturningAll | ||
@@ -196,5 +205,3 @@ .select(['email', '=', USERS[0].email]) | ||
it('inserts one returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS[0]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -209,3 +216,3 @@ expect(Object.keys(insertReturn).length).toEqual(1); | ||
.insert() | ||
.getReturns(post0); | ||
.getOne(post0); | ||
expect(updaterPost.id).toBeGreaterThan(0); | ||
@@ -223,5 +230,3 @@ expect(updaterPost.title).toEqual(POSTS[0].title); | ||
it('inserts one configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningAll | ||
.insert() | ||
.getReturns(USERS[0]); | ||
const insertReturn = yield userMapperReturningAll.insert().getOne(USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -233,11 +238,11 @@ const expectedUser = Object.assign({}, USERS[0], { id: insertReturn.id }); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns({}); | ||
userMapperReturningAll.insert().getOne({}); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run({}); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getReturns({ email: 'xyz@pdq.xyz' }); | ||
userMapperReturningAll.insert().getOne({ email: 'xyz@pdq.xyz' }); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().run({ email: 'xyz@pdq.xyz' }); | ||
// @ts-expect-error - only requested columns are returned | ||
(yield userMapperReturningID.insert().getReturns(USERS[0])).name; | ||
(yield userMapperReturningID.insert().getOne(USERS[0])).name; | ||
// @ts-expect-error - only requested columns are returned | ||
@@ -265,3 +270,3 @@ (yield userMapperReturningDefault.insert().run(USERS[0])).name; | ||
.insert() | ||
.getReturns(insertedUser1); | ||
.getOne(insertedUser1); | ||
const readUser1 = yield insertTransformMapper | ||
@@ -273,8 +278,6 @@ .select({ | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.name).toEqual(`${insertedUser1.firstName} ${insertedUser1.lastName}`); | ||
yield insertTransformMapper | ||
.insert() | ||
.getReturns([insertedUser2, insertedUser3]); | ||
yield insertTransformMapper.insert().getAll([insertedUser2, insertedUser3]); | ||
const readUsers = yield insertTransformMapper | ||
.select(['id', '>', insertReturn.id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -297,7 +300,7 @@ expect(readUsers[0].name).toEqual(`${insertedUser2.firstName} ${insertedUser2.lastName}`); | ||
.insert() | ||
.getReturns(userRow1); | ||
.getOne(userRow1); | ||
expect(insertReturn).toEqual(insertReturnedUser1); | ||
const insertReturns = yield insertReturnTransformMapper | ||
.insert() | ||
.getReturns([userRow2, userRow3]); | ||
.getAll([userRow2, userRow3]); | ||
expect(insertReturns).toEqual([insertReturnedUser2, insertReturnedUser3]); | ||
@@ -323,7 +326,7 @@ })); | ||
.insert() | ||
.getReturns(insertedUser1); | ||
.getOne(insertedUser1); | ||
expect(insertReturn).toEqual(insertReturnedUser1); | ||
const insertReturns = yield insertAndReturnTransformMapper | ||
.insert() | ||
.getReturns([insertedUser2, insertedUser3]); | ||
.getAll([insertedUser2, insertedUser3]); | ||
expect(insertReturns).toEqual([insertReturnedUser2, insertReturnedUser3]); | ||
@@ -334,7 +337,7 @@ })); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getReturns(USERS[0]); | ||
yield insertTransformMapper.insert().getOne(USERS[0]); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().run(USERS[0]); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getReturns(selectedUser1); | ||
yield insertTransformMapper.insert().getOne(selectedUser1); | ||
// @ts-expect-error - requires InsertedObject as input | ||
@@ -341,0 +344,0 @@ yield insertTransformMapper.insert().run(selectedUser1); |
@@ -39,3 +39,3 @@ /** | ||
// ); | ||
// const users = await parameterization.getMany(db, { | ||
// const users = await parameterization.getAll(db, { | ||
// name: USERS[0].name, | ||
@@ -56,3 +56,3 @@ // }); | ||
// // @ts-expect-error - errors on invalid parameter names | ||
// parameterization.getMany(db, { notThere: 'foo' }); | ||
// parameterization.getAll(db, { notThere: 'foo' }); | ||
// // @ts-expect-error - errors on invalid column names | ||
@@ -69,3 +69,3 @@ // users[0].notThere; | ||
.modify((qb) => qb.where('name', '=', USERS[0].name).orderBy('handle', 'desc')) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -85,3 +85,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getMany(); | ||
.getAll(); | ||
expect(users).toEqual([ | ||
@@ -130,6 +130,6 @@ Object.assign(Object.assign({}, USERS[2]), { id: 3 }), | ||
}); | ||
describe('select() getMany()', () => { | ||
describe('select() getAll()', () => { | ||
it('selects nothing when nothing matches filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapper.insert().run(USERS); | ||
const users = yield userMapper.select({ name: 'Not There' }).getMany(); | ||
const users = yield userMapper.select({ name: 'Not There' }).getAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -140,3 +140,3 @@ })); | ||
// Test selecting all | ||
const users = yield userMapper.select().getMany(); | ||
const users = yield userMapper.select().getAll(); | ||
expect(users.length).toEqual(USERS.length); | ||
@@ -153,3 +153,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -163,3 +163,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -171,3 +171,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select(['name', '=', USERS[0].name]).getMany(); | ||
let users = yield userMapper.select(['name', '=', USERS[0].name]).getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -177,3 +177,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getMany(); | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -185,3 +185,3 @@ })); | ||
.select(sql `name != ${USERS[0].name}`) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -196,3 +196,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -206,3 +206,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -214,3 +214,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select(['name', '=', USERS[0].name]).getMany(); | ||
let users = yield userMapper.select(['name', '=', USERS[0].name]).getAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -220,7 +220,7 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getMany(); | ||
users = yield userMapper.select(['name', '=', 'nonexistent']).getAll(); | ||
expect(users.length).toEqual(0); | ||
})); | ||
it('selects many returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getReturns(USERS); | ||
const ids = yield userMapper.insert().getAll(USERS); | ||
const mapper = new TableMapper(db, 'users', { | ||
@@ -230,4 +230,4 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getMany())[0].h; | ||
const users = yield mapper.select({ name: USERS[0].name }).getMany(); | ||
(yield mapper.select().getAll())[0].h; | ||
const users = yield mapper.select({ name: USERS[0].name }).getAll(); | ||
expect(users).toEqual([ | ||
@@ -247,20 +247,20 @@ { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getMany())[0].name; | ||
(yield mapper.select().getAll())[0].name; | ||
})); | ||
})); | ||
ignore('detects select() getMany() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
ignore('detects select() getAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select().getMany())[0].notThere; | ||
(yield userMapper.select().getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getMany())[0].notThere; | ||
(yield userMapper.select({}).getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
// prettier-ignore | ||
(yield userMapper.select({ name: "Sue" }).getMany())[0].notThere; | ||
(yield userMapper.select({ name: "Sue" }).getAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select(["name", "=", "Sue"]).getMany())[0].notThere; | ||
(yield userMapper.select(["name", "=", "Sue"]).getAll())[0].notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getMany() | ||
.getAll() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -271,3 +271,3 @@ )[0].notThere; | ||
.select(sql `name = 'Sue'`) | ||
.getMany() | ||
.getAll() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -314,3 +314,3 @@ )[0].notThere; | ||
it('selects the first row with a compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const userIDs = yield userMapper.insert().getReturns(USERS); | ||
const userIDs = yield userMapper.insert().getAll(USERS); | ||
const user = yield userMapper | ||
@@ -343,3 +343,3 @@ .select(({ and, cmpr }) => and([cmpr('name', '=', USERS[0].name), cmpr('id', '>', userIDs[0].id)])) | ||
it('selects one returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getReturns(USERS); | ||
const ids = yield userMapper.insert().getAll(USERS); | ||
const mapper = new TableMapper(db, 'users', { | ||
@@ -354,3 +354,3 @@ selectedColumns: ['id', 'handle as h'], | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getMany())[0].name; | ||
(yield mapper.select().getAll())[0].name; | ||
})); | ||
@@ -357,0 +357,0 @@ })); |
@@ -34,4 +34,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
describe('updating rows via TableMapper', () => { | ||
it('updates returning zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('updates nothing returning zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const success = yield userMapperReturningAll | ||
.update({ id: 1 }) | ||
.run(updateValues); | ||
expect(success).toBe(false); | ||
const updateCount = yield userMapperReturningAll | ||
@@ -43,10 +47,12 @@ .update({ id: 1 }) | ||
.update({ id: 1 }) | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
expect(updates.length).toEqual(0); | ||
const update = yield userMapperReturningID | ||
.update({ id: 1 }) | ||
.getOne(updateValues); | ||
expect(update).toBeNull(); | ||
})); | ||
it('updates returning non-zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('updates something returning non-zero update count', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const insertReturn0 = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS[0]); | ||
const insertReturn0 = yield userMapperReturningID.insert().getOne(USERS[0]); | ||
yield userMapperReturningID.insert().run(USERS[1]); | ||
@@ -58,6 +64,6 @@ yield userMapperReturningID.insert().run(USERS[2]); | ||
expect(updateCount1).toEqual(1); | ||
const readUser = yield userMapperReturningID | ||
const readUser1 = yield userMapperReturningID | ||
.select(['id', '=', insertReturn0.id]) | ||
.getOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.email).toEqual(updateValues.email); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.email).toEqual(updateValues.email); | ||
const updateCount2 = yield userMapperReturningAll | ||
@@ -69,17 +75,32 @@ .update({ name: 'Sue' }) | ||
.select(['name', '=', 'Sue']) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
expect(readUsers[0].email).toEqual(updateValues.email); | ||
expect(readUsers[1].email).toEqual(updateValues.email); | ||
// prettier-ignore | ||
const updates = yield userMapperReturningID.update().getAll({ | ||
name: 'Every User 1', | ||
}); | ||
expect(updates).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]); | ||
const update = yield userMapperReturningID | ||
.update({ id: readUsers[0].id }) | ||
.getOne({ | ||
name: 'Every User 2', | ||
}); | ||
expect(update).toEqual({ id: 1 }); | ||
const readUser2 = yield userMapperReturningID | ||
.select(['id', '=', 1]) | ||
.getOne(); | ||
expect(readUser2 === null || readUser2 === void 0 ? void 0 : readUser2.name).toEqual('Every User 2'); | ||
const updateCount = yield userMapperReturningID.update().getCount({ | ||
name: "Every User", | ||
name: 'Every User 3', | ||
}); | ||
expect(updateCount).toEqual(3); | ||
const success = yield userMapperReturningID.update().run({ | ||
name: 'Every User 4', | ||
}); | ||
expect(success).toBe(true); | ||
})); | ||
it('updates returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapperReturningID.insert().run(USERS[0]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS[1]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(USERS[1]); | ||
yield userMapperReturningID.insert().run(USERS[2]); | ||
@@ -90,3 +111,3 @@ // Verify that update performs the correct change on the correct row. | ||
.update({ id: insertReturn.id }) | ||
.getReturns(updateValues1); | ||
.getAll(updateValues1); | ||
expect(updateReturns1).toEqual([{ id: insertReturn.id }]); | ||
@@ -101,3 +122,3 @@ let readUser = yield userMapperReturningID | ||
.update({ email: updateValues1.email }) | ||
.getReturns(updateValues2); | ||
.getAll(updateValues2); | ||
expect(updateReturns2).toEqual([ | ||
@@ -117,3 +138,3 @@ { | ||
.update({ name: 'Sue' }) | ||
.getReturns(updateValues3); | ||
.getAll(updateValues3); | ||
expect(updateReturns3.length).toEqual(3); | ||
@@ -125,3 +146,3 @@ expect(updateReturns3[0].handle).toEqual(USERS[0].handle); | ||
.select(['name', '=', updateValues3.name]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -133,3 +154,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getReturns({ email: 'new.email@xyz.pdq' }); | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -140,3 +161,3 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -148,3 +169,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getReturns({ email: 'new.email@xyz.pdq' }); | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -155,13 +176,11 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
})); | ||
it('updates configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningAll | ||
.update({ name: 'Sue' }) | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
const expectedUsers = [ | ||
@@ -174,9 +193,7 @@ Object.assign({}, USERS[0], updateValues, { id: insertReturns[0].id }), | ||
it('updates all rows when no filter is given', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningIDAndHandle | ||
.update() | ||
.getReturns(updateValues); | ||
.getAll(updateValues); | ||
const expectedUsers = USERS.map((user, i) => { | ||
@@ -186,3 +203,3 @@ return { id: insertReturns[i].id, handle: user.handle }; | ||
expect(updateReturns).toEqual(expectedUsers); | ||
const readUsers = yield userMapperReturningID.select().getMany(); | ||
const readUsers = yield userMapperReturningID.select().getAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -194,5 +211,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a binary operator', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -205,3 +220,3 @@ const updateCount = yield userMapperReturningAll | ||
.select(['id', '>', insertReturns[0].id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -213,5 +228,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a kysely expression', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -224,3 +237,3 @@ const updateCount = yield userMapperReturningDefault | ||
.select(['id', '>', insertReturns[0].id]) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -232,5 +245,3 @@ for (const user of readUsers) { | ||
it('updates rows indicated by a where expression filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID | ||
.insert() | ||
.getReturns(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const updateValues1 = { email: 'foo@xyz.pdq' }; | ||
@@ -250,3 +261,3 @@ const updateCount = yield userMapperReturningAll | ||
])) | ||
.getReturns(updateValues2); | ||
.getAll(updateValues2); | ||
expect(updateReturns).toEqual([ | ||
@@ -267,9 +278,9 @@ { id: insertReturns[0].id }, | ||
{ notThere: 'xyz' }) | ||
.getReturns({ email: 'abc@def.ghi' }); | ||
.getAll({ email: 'abc@def.ghi' }); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getReturns({ | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getAll({ | ||
email: 'abc@def.ghi', | ||
}); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getReturns({ | ||
userMapperReturningID.update(['notThere', '=', 'foo']).getAll({ | ||
email: 'abc@def.ghi', | ||
@@ -280,4 +291,4 @@ }); | ||
// @ts-expect-error - update must only have table columns | ||
.getReturns({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getReturns( | ||
.getAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getAll( | ||
// @ts-expect-error - update must only have table columns | ||
@@ -291,6 +302,6 @@ { notThere: 'xyz@pdq.xyz' }); | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getReturns(USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(USERS[0]))[0].name; | ||
// @ts-expect-error - only requested columns are accessible | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getReturns(USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(USERS[0]))[0].name; | ||
yield userMapperReturningID | ||
@@ -305,3 +316,3 @@ .update(({ or, cmpr }) => | ||
or([cmpr('notThere', '=', 'xyz'), cmpr('alsoNotThere', '=', 'Sue')])) | ||
.getReturns(USERS[0]); | ||
.getAll(USERS[0]); | ||
})); | ||
@@ -326,3 +337,3 @@ }); | ||
.insert() | ||
.getReturns([userRow1, userRow2, userRow3]); | ||
.getAll([userRow1, userRow2, userRow3]); | ||
const updaterUser1 = UpdaterUser.create(0, Object.assign({}, userObject1, { firstName: 'Suzanne' })); | ||
@@ -334,3 +345,3 @@ const updateReturns = yield mapper | ||
])) | ||
.getReturns(updaterUser1); | ||
.getAll(updaterUser1); | ||
expect(updateReturns).toEqual([ | ||
@@ -343,3 +354,3 @@ { id: insertReturns[0].id }, | ||
.modify((qb) => qb.orderBy('id')) | ||
.getMany(); | ||
.getAll(); | ||
expect(readUsers).toEqual([ | ||
@@ -369,6 +380,6 @@ Object.assign({}, userRow1, { | ||
.insert() | ||
.getReturns(userRow1); | ||
.getOne(userRow1); | ||
const updateReturn = yield updateReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getReturns({ name: 'Suzanne Smith' }); | ||
.getAll({ name: 'Suzanne Smith' }); | ||
expect(updateReturn).toEqual([ | ||
@@ -395,6 +406,6 @@ new ReturnedUser(insertReturn.id, 'Suzanne', 'Smith', '(handle)', '(email)'), | ||
.insert() | ||
.getReturns(userRow1); | ||
.getOne(userRow1); | ||
const updateReturn = yield updateAndReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getReturns(UpdaterUser.create(0, userObject1)); | ||
.getAll(UpdaterUser.create(0, userObject1)); | ||
expect(updateReturn).toEqual([ | ||
@@ -401,0 +412,0 @@ new ReturnedUser(insertReturn.id, userObject1.firstName, userObject1.lastName, userObject1.handle, userObject1.email), |
@@ -38,3 +38,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const insertedUser1 = new KeyedUser(0, USERS[0].name, USERS[0].handle, USERS[0].email); | ||
const insertReturn1 = (yield userMapper.insert().getReturns(insertedUser1)); | ||
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1)); | ||
expect(insertReturn1).not.toBeNull(); | ||
@@ -48,3 +48,3 @@ expect(insertReturn1.id).toBeGreaterThan(0); | ||
const insertedUser2 = new KeyedUser(10, USERS[1].name, USERS[1].handle, USERS[1].email); | ||
const insertReturn2 = (yield userMapper.insert().getReturns(insertedUser2)); | ||
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2)); | ||
expect(insertReturn2).toEqual(insertedUser2); | ||
@@ -115,3 +115,3 @@ const selectedUser2 = yield userMapper.selectByKey(insertReturn2.id); | ||
const insertedUser = new KeyedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getReturns(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
expect(insertReturn).not.toBeNull(); | ||
@@ -133,3 +133,3 @@ expect(insertReturn.serialNo).toBeGreaterThan(0); | ||
.update(['id', '=', insertReturn.serialNo]) | ||
.getReturns({ | ||
.getAll({ | ||
name: 'Foo Foo', | ||
@@ -187,3 +187,3 @@ }); | ||
const insertedUser = new KeyedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getReturns(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
expect(insertReturn).not.toBeNull(); | ||
@@ -190,0 +190,0 @@ expect(insertReturn.id).toBeGreaterThan(0); |
{ | ||
"name": "kysely-mapper", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Joseph T. Lapp <arachnojoe@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
685908
8059
0