kysely-mapper
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -38,3 +38,3 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selection, Insertable } from 'kysely'; | ||
*/ | ||
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
returnAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
/** | ||
@@ -50,3 +50,3 @@ * Inserts the provided object into the table as a row, first transforming | ||
*/ | ||
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>; | ||
returnOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>; | ||
/** | ||
@@ -53,0 +53,0 @@ * Runs the query, inserting rows into the table without returning any columns. |
@@ -53,3 +53,3 @@ "use strict"; | ||
} | ||
getAll(objs) { | ||
returnAll(objs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -69,3 +69,3 @@ if (this.returnColumns.length === 0) { | ||
} | ||
getOne(obj) { | ||
returnOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -72,0 +72,0 @@ if (this.returnColumns.length === 0) { |
@@ -20,3 +20,3 @@ import { Compilable, Kysely } from 'kysely'; | ||
*/ | ||
getAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
returnAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
/** | ||
@@ -30,4 +30,4 @@ * Executes the query with all parameters replaced, returning the first | ||
*/ | ||
getOne<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject | null>; | ||
returnOne<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject | null>; | ||
} | ||
//# sourceMappingURL=paramed-row-query.d.ts.map |
@@ -45,3 +45,3 @@ "use strict"; | ||
*/ | ||
getAll(db, params) { | ||
returnAll(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -60,3 +60,3 @@ const results = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").execute(db, params); | ||
*/ | ||
getOne(db, params) { | ||
returnOne(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -63,0 +63,0 @@ const result = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").executeTakeFirst(db, params); |
@@ -22,3 +22,3 @@ import { Kysely, SelectQueryBuilder } from 'kysely'; | ||
*/ | ||
getAll(): Promise<SelectedObject[]>; | ||
returnAll(): Promise<SelectedObject[]>; | ||
/** | ||
@@ -29,3 +29,3 @@ * Retrieves a single row from the table, using `selectTransform` | ||
*/ | ||
getOne(): Promise<SelectedObject | null>; | ||
returnOne(): Promise<SelectedObject | null>; | ||
/** | ||
@@ -32,0 +32,0 @@ * Modifies the underlying Kysely query builder. All columns given in |
@@ -33,3 +33,3 @@ "use strict"; | ||
*/ | ||
getAll() { | ||
returnAll() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -47,3 +47,3 @@ const results = yield this.qb.execute(); | ||
*/ | ||
getOne() { | ||
returnOne() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -50,0 +50,0 @@ const result = yield this.qb.executeTakeFirst(); |
@@ -49,4 +49,4 @@ import { Kysely, Selection, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely'; | ||
*/ | ||
getAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
getAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>; | ||
returnAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
returnAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>; | ||
/** | ||
@@ -64,4 +64,4 @@ * Updates rows with the values that result from transforming the object via | ||
*/ | ||
getOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>; | ||
getOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>; | ||
returnOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>; | ||
returnOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>; | ||
/** | ||
@@ -68,0 +68,0 @@ * Runs the query, updating rows, without returning any columns. |
@@ -67,3 +67,3 @@ "use strict"; | ||
} | ||
getAll(obj) { | ||
returnAll(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -83,3 +83,3 @@ if (this.returnColumns.length === 0) { | ||
} | ||
getOne(obj) { | ||
returnOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -86,0 +86,0 @@ if (this.returnColumns.length === 0) { |
@@ -41,3 +41,3 @@ "use strict"; | ||
expect(success).toBe(true); | ||
const users = yield testMapper.select().getAll(); | ||
const users = yield testMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -57,3 +57,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count2).toEqual(BigInt(2)); | ||
const users = yield defaultMapper.select().getAll(); | ||
const users = yield defaultMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -76,3 +76,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count2).toEqual(2); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -85,3 +85,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count1).toEqual(3); | ||
const users1 = yield userMapper.select().getAll(); | ||
const users1 = yield userMapper.select().returnAll(); | ||
expect(users1.length).toEqual(0); | ||
@@ -91,3 +91,3 @@ yield userMapper.insert().run(test_objects_1.USERS); | ||
expect(success).toBe(true); | ||
const users2 = yield userMapper.select().getAll(); | ||
const users2 = yield userMapper.select().returnAll(); | ||
expect(users2.length).toEqual(0); | ||
@@ -118,3 +118,3 @@ })); | ||
expect(count1).toEqual(2); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -136,3 +136,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
expect(count2).toEqual(1); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -155,3 +155,3 @@ })); | ||
// expect(count2).toEqual(2); | ||
// const users = await userMapper.select().getAll(); | ||
// const users = await userMapper.select().returnAll(); | ||
// expect(users.length).toEqual(1); | ||
@@ -163,3 +163,3 @@ // expect(users[0].handle).toEqual(USERS[1].handle); | ||
// expect(count3).toEqual(1); | ||
// const users2 = await userMapper.select().getAll(); | ||
// const users2 = await userMapper.select().returnAll(); | ||
// expect(users2.length).toEqual(0); | ||
@@ -166,0 +166,0 @@ // ignore('parameterization type errors', () => { |
@@ -69,3 +69,3 @@ "use strict"; | ||
expect(success).toBe(true); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -82,6 +82,6 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
})); | ||
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); | ||
it('inserts multiple via returnAll() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().returnAll(test_objects_1.USERS); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -98,6 +98,8 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
})); | ||
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]); | ||
it('inserts multiple via returnOne() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault | ||
.insert() | ||
.returnOne(test_objects_1.USERS[0]); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(1); | ||
@@ -113,3 +115,3 @@ expect(readUsers[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
it('inserts multiple returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID.insert().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
expect(insertReturns.length).toEqual(3); | ||
@@ -120,3 +122,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
} | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -131,3 +133,3 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
.insert() | ||
.getAll([post0, post1, post2]); | ||
.returnAll([post0, post1, post2]); | ||
expect(updateReturns.length).toEqual(3); | ||
@@ -149,5 +151,5 @@ for (let i = 0; i < updateReturns.length; i++) { | ||
.insert() | ||
.getAll(test_objects_1.USERS); | ||
.returnAll(test_objects_1.USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -161,5 +163,5 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
.insert() | ||
.getAll(test_objects_1.USERS); | ||
.returnAll(test_objects_1.USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -171,3 +173,5 @@ 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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningAll | ||
.insert() | ||
.returnAll(test_objects_1.USERS); | ||
for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
@@ -180,11 +184,11 @@ expect(insertReturns[i].id).toBeGreaterThan(0); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getAll([{}]); | ||
userMapperReturningAll.insert().returnAll([{}]); | ||
// @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().getAll([{ email: 'xyz@pdq.xyz' }]); | ||
userMapperReturningAll.insert().returnAll([{ 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().getAll([test_objects_1.USERS[0]]))[0].handle; | ||
(yield userMapperReturningID.insert().returnAll([test_objects_1.USERS[0]]))[0].handle; | ||
// @ts-expect-error - only configured columns are returned | ||
@@ -200,3 +204,3 @@ (yield userMapperReturningID.insert().run([test_objects_1.USERS[0]]))[0].handle; | ||
.select('email', '=', test_objects_1.USERS[0].email) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(test_objects_1.USERS[0].email); | ||
@@ -209,7 +213,9 @@ })); | ||
.select('email', '=', test_objects_1.USERS[0].email) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(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().getOne(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.returnOne(test_objects_1.USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -219,3 +225,3 @@ expect(Object.keys(insertReturn).length).toEqual(1); | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(test_objects_1.USERS[0].email); | ||
@@ -225,3 +231,3 @@ const post0 = Object.assign({}, test_objects_1.POSTS[0], { userId: insertReturn.id }); | ||
.insert() | ||
.getOne(post0); | ||
.returnOne(post0); | ||
expect(updateReturn.id).toBeGreaterThan(0); | ||
@@ -235,3 +241,3 @@ expect(updateReturn.t).toEqual(test_objects_1.POSTS[0].title); | ||
])) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readPost0 === null || readPost0 === void 0 ? void 0 : readPost0.likeCount).toEqual(post0.likeCount); | ||
@@ -246,3 +252,5 @@ (0, test_utils_1.ignore)('check return types', () => { | ||
it('inserts one configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningAll.insert().getOne(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningAll | ||
.insert() | ||
.returnOne(test_objects_1.USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -254,11 +262,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().getOne({}); | ||
userMapperReturningAll.insert().returnOne({}); | ||
// @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().getOne({ email: 'xyz@pdq.xyz' }); | ||
userMapperReturningAll.insert().returnOne({ 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().getOne(test_objects_1.USERS[0])).name; | ||
(yield userMapperReturningID.insert().returnOne(test_objects_1.USERS[0])).name; | ||
// @ts-expect-error - only requested columns are returned | ||
@@ -286,3 +294,3 @@ (yield userMapperReturningDefault.insert().run(test_objects_1.USERS[0])).name; | ||
.insert() | ||
.getOne(test_objects_1.insertedUser1); | ||
.returnOne(test_objects_1.insertedUser1); | ||
const readUser1 = yield insertTransformMapper | ||
@@ -292,8 +300,10 @@ .select({ | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.name).toEqual(`${test_objects_1.insertedUser1.firstName} ${test_objects_1.insertedUser1.lastName}`); | ||
yield insertTransformMapper.insert().getAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
yield insertTransformMapper | ||
.insert() | ||
.returnAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
const readUsers = yield insertTransformMapper | ||
.select('id', '>', insertReturn.id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -316,7 +326,7 @@ expect(readUsers[0].name).toEqual(`${test_objects_1.insertedUser2.firstName} ${test_objects_1.insertedUser2.lastName}`); | ||
.insert() | ||
.getOne(test_objects_1.userRow1); | ||
.returnOne(test_objects_1.userRow1); | ||
expect(insertReturn).toEqual(test_objects_1.insertReturnedUser1); | ||
const insertReturns = yield insertReturnTransformMapper | ||
.insert() | ||
.getAll([test_objects_1.userRow2, test_objects_1.userRow3]); | ||
.returnAll([test_objects_1.userRow2, test_objects_1.userRow3]); | ||
expect(insertReturns).toEqual([test_objects_1.insertReturnedUser2, test_objects_1.insertReturnedUser3]); | ||
@@ -342,7 +352,7 @@ })); | ||
.insert() | ||
.getOne(test_objects_1.insertedUser1); | ||
.returnOne(test_objects_1.insertedUser1); | ||
expect(insertReturn).toEqual(test_objects_1.insertReturnedUser1); | ||
const insertReturns = yield insertAndReturnTransformMapper | ||
.insert() | ||
.getAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
.returnAll([test_objects_1.insertedUser2, test_objects_1.insertedUser3]); | ||
expect(insertReturns).toEqual([test_objects_1.insertReturnedUser2, test_objects_1.insertReturnedUser3]); | ||
@@ -353,7 +363,7 @@ })); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getOne(test_objects_1.USERS[0]); | ||
yield insertTransformMapper.insert().returnOne(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().getOne(test_objects_1.selectedUser1); | ||
yield insertTransformMapper.insert().returnOne(test_objects_1.selectedUser1); | ||
// @ts-expect-error - requires InsertedObject as input | ||
@@ -360,0 +370,0 @@ yield insertTransformMapper.insert().run(test_objects_1.selectedUser1); |
@@ -89,3 +89,3 @@ "use strict"; | ||
// @ts-expect-error - ensure that return type is User | ||
.getOne(new test_types_1.User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name; | ||
.returnOne(new test_types_1.User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name; | ||
})); | ||
@@ -92,0 +92,0 @@ it('dummy test', () => { |
@@ -43,3 +43,3 @@ "use strict"; | ||
// ); | ||
// const users = await parameterization.getAll(db, { | ||
// const users = await parameterization.returnAll(db, { | ||
// name: USERS[0].name, | ||
@@ -52,3 +52,3 @@ // }); | ||
// ((_: string) => {})(users[0].handle); | ||
// const user = await parameterization.getOne(db, { | ||
// const user = await parameterization.returnOne(db, { | ||
// name: USERS[0].name, | ||
@@ -61,3 +61,3 @@ // }); | ||
// // @ts-expect-error - errors on invalid parameter names | ||
// parameterization.getAll(db, { notThere: 'foo' }); | ||
// parameterization.returnAll(db, { notThere: 'foo' }); | ||
// // @ts-expect-error - errors on invalid column names | ||
@@ -74,3 +74,3 @@ // users[0].notThere; | ||
.modify((qb) => qb.where('name', '=', test_objects_1.USERS[0].name).orderBy('handle', 'desc')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -82,3 +82,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[2].handle); | ||
.modify((qb) => qb.where('name', '=', test_objects_1.USERS[0].name).orderBy('handle', 'desc')) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[2].handle); | ||
@@ -91,3 +91,3 @@ })); | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users).toEqual([ | ||
@@ -106,3 +106,3 @@ Object.assign(Object.assign({}, test_objects_1.USERS[2]), { id: 3 }), | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user).toEqual(Object.assign(Object.assign({}, test_objects_1.USERS[2]), { id: 3 })); | ||
@@ -126,3 +126,3 @@ // Ensure that columns can be addressed by name. | ||
yield mapper.insert().run(test_objects_1.USERS); | ||
const users = yield mapper.select([3, 'Sue']).getAll(); | ||
const users = yield mapper.select([3, 'Sue']).returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -148,3 +148,3 @@ expect(users[0].name).toEqual(test_objects_1.USERS[2].name); | ||
yield mapper.insert().run(test_objects_1.USERS); | ||
const users = yield mapper.select(['Sue', 3]).getAll(); | ||
const users = yield mapper.select(['Sue', 3]).returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -187,6 +187,6 @@ expect(users[0].name).toEqual(test_objects_1.USERS[2].name); | ||
}); | ||
describe('select() getAll()', () => { | ||
describe('select() returnAll()', () => { | ||
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' }).getAll(); | ||
const users = yield userMapper.select({ name: 'Not There' }).returnAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -197,3 +197,3 @@ })); | ||
// Test selecting all | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(test_objects_1.USERS.length); | ||
@@ -207,7 +207,7 @@ for (let i = 0; i < test_objects_1.USERS.length; i++) { | ||
// Test selecting via key value | ||
const users1 = yield userMapper.select(2).getAll(); | ||
const users1 = yield userMapper.select(2).returnAll(); | ||
expect(users1.length).toEqual(1); | ||
expect(users1[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
// Test selecting via key tuple | ||
const users2 = yield userMapper.select([2]).getAll(); | ||
const users2 = yield userMapper.select([2]).returnAll(); | ||
expect(users2.length).toEqual(1); | ||
@@ -222,3 +222,3 @@ expect(users2[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -232,3 +232,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -240,3 +240,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).getAll(); | ||
let users = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -246,3 +246,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select('name', '=', 'nonexistent').getAll(); | ||
users = yield userMapper.select('name', '=', 'nonexistent').returnAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -254,3 +254,3 @@ })); | ||
.select((0, kysely_1.sql) `name != ${test_objects_1.USERS[0].name}`) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -265,3 +265,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[1].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -275,3 +275,3 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -283,3 +283,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).getAll(); | ||
let users = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -289,7 +289,7 @@ expect(users[0].handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select('name', '=', 'nonexistent').getAll(); | ||
users = yield userMapper.select('name', '=', 'nonexistent').returnAll(); | ||
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().getAll(test_objects_1.USERS); | ||
const ids = yield userMapper.insert().returnAll(test_objects_1.USERS); | ||
const mapper = new table_mapper_1.TableMapper(db, 'users', { | ||
@@ -299,4 +299,4 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getAll())[0].h; | ||
const users = yield mapper.select({ name: test_objects_1.USERS[0].name }).getAll(); | ||
(yield mapper.select().returnAll())[0].h; | ||
const users = yield mapper.select({ name: test_objects_1.USERS[0].name }).returnAll(); | ||
expect(users).toEqual([ | ||
@@ -316,20 +316,20 @@ { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getAll())[0].name; | ||
(yield mapper.select().returnAll())[0].name; | ||
})); | ||
})); | ||
(0, test_utils_1.ignore)('detects select() getAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, test_utils_1.ignore)('detects select() returnAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select().getAll())[0].notThere; | ||
(yield userMapper.select().returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getAll())[0].notThere; | ||
(yield userMapper.select({}).returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
// prettier-ignore | ||
(yield userMapper.select({ name: "Sue" }).getAll())[0].notThere; | ||
(yield userMapper.select({ name: "Sue" }).returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select("name", "=", "Sue").getAll())[0].notThere; | ||
(yield userMapper.select("name", "=", "Sue").returnAll())[0].notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getAll() | ||
.returnAll() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -340,3 +340,3 @@ )[0].notThere; | ||
.select((0, kysely_1.sql) `name = 'Sue'`) | ||
.getAll() | ||
.returnAll() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -346,8 +346,8 @@ )[0].notThere; | ||
}); | ||
describe('select() getOne()', () => { | ||
describe('select() returnOne()', () => { | ||
it('selects the first row with no filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
let user = yield userMapper.select().getOne(); | ||
let user = yield userMapper.select().returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
user = yield userMapper.select({}).getOne(); | ||
user = yield userMapper.select({}).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
@@ -357,3 +357,3 @@ })); | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
let user = yield userMapper.select({ name: test_objects_1.USERS[0].name }).getOne(); | ||
let user = yield userMapper.select({ name: test_objects_1.USERS[0].name }).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
@@ -365,3 +365,3 @@ user = yield userMapper | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[2].handle); | ||
@@ -372,6 +372,6 @@ })); | ||
// Test selecting by condition (with result) | ||
let user = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).getOne(); | ||
let user = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no result) | ||
user = yield userMapper.select('name', '=', 'nonexistent').getOne(); | ||
user = yield userMapper.select('name', '=', 'nonexistent').returnOne(); | ||
expect(user).toBeNull(); | ||
@@ -383,10 +383,10 @@ })); | ||
.select((0, kysely_1.sql) `name != ${test_objects_1.USERS[0].name}`) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[1].handle); | ||
})); | ||
it('selects the first row with a compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const userIDs = yield userMapper.insert().getAll(test_objects_1.USERS); | ||
const userIDs = yield userMapper.insert().returnAll(test_objects_1.USERS); | ||
const user = yield userMapper | ||
.select(({ and, cmpr }) => and([cmpr('name', '=', test_objects_1.USERS[0].name), cmpr('id', '>', userIDs[0].id)])) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[2].handle); | ||
@@ -396,3 +396,3 @@ })); | ||
yield userMapper.insert().run(test_objects_1.USERS); | ||
let user = yield userMapper.select({ name: test_objects_1.USERS[0].name }).getOne(); | ||
let user = yield userMapper.select({ name: test_objects_1.USERS[0].name }).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
@@ -404,3 +404,3 @@ user = yield userMapper | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[2].handle); | ||
@@ -411,10 +411,10 @@ })); | ||
// Test selecting by condition (with result) | ||
let user = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).getOne(); | ||
let user = yield userMapper.select('name', '=', test_objects_1.USERS[0].name).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(test_objects_1.USERS[0].handle); | ||
// Test selecting by condition (no result) | ||
user = yield userMapper.select('name', '=', 'nonexistent').getOne(); | ||
user = yield userMapper.select('name', '=', 'nonexistent').returnOne(); | ||
expect(user).toBeNull(); | ||
})); | ||
it('selects one returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getAll(test_objects_1.USERS); | ||
const ids = yield userMapper.insert().returnAll(test_objects_1.USERS); | ||
const mapper = new table_mapper_1.TableMapper(db, 'users', { | ||
@@ -424,22 +424,22 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getOne()).h; | ||
const user = yield mapper.select({ handle: test_objects_1.USERS[0].handle }).getOne(); | ||
(yield mapper.select().returnOne()).h; | ||
const user = yield mapper.select({ handle: test_objects_1.USERS[0].handle }).returnOne(); | ||
expect(user).toEqual({ id: ids[0].id, h: test_objects_1.USERS[0].handle }); | ||
(0, test_utils_1.ignore)('inaccessible types are not allowed', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getAll())[0].name; | ||
(yield mapper.select().returnAll())[0].name; | ||
})); | ||
})); | ||
(0, test_utils_1.ignore)('detects select() getOne() type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, test_utils_1.ignore)('detects select() returnOne() type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getOne()).notThere; | ||
(yield userMapper.select({}).returnOne()).notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
(yield userMapper.select({ name: 'Sue' }).getOne()).notThere; | ||
(yield userMapper.select({ name: 'Sue' }).returnOne()).notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select("name", "=", "Sue").getOne()).notThere; | ||
(yield userMapper.select("name", "=", "Sue").returnOne()).notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getOne() | ||
.returnOne() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -450,3 +450,3 @@ ).notThere; | ||
.select((0, kysely_1.sql) `name = 'Sue'`) | ||
.getOne() | ||
.returnOne() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -453,0 +453,0 @@ ).notThere; |
@@ -49,7 +49,7 @@ "use strict"; | ||
.update({ id: 1 }) | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
expect(updates.length).toEqual(0); | ||
const update = yield userMapperReturningID | ||
.update({ id: 1 }) | ||
.getOne(updateValues); | ||
.returnOne(updateValues); | ||
expect(update).toBeNull(); | ||
@@ -59,3 +59,5 @@ })); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const insertReturn0 = yield userMapperReturningID.insert().getOne(test_objects_1.USERS[0]); | ||
const insertReturn0 = yield userMapperReturningID | ||
.insert() | ||
.returnOne(test_objects_1.USERS[0]); | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[1]); | ||
@@ -69,3 +71,3 @@ yield userMapperReturningID.insert().run(test_objects_1.USERS[2]); | ||
.select('id', '=', insertReturn0.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.email).toEqual(updateValues.email); | ||
@@ -78,7 +80,7 @@ const updateCount2 = yield userMapperReturningAll | ||
.select('name', '=', 'Sue') | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
expect(readUsers[0].email).toEqual(updateValues.email); | ||
expect(readUsers[1].email).toEqual(updateValues.email); | ||
const updates = yield userMapperReturningID.update().getAll({ | ||
const updates = yield userMapperReturningID.update().returnAll({ | ||
name: 'Every User 1', | ||
@@ -89,7 +91,9 @@ }); | ||
.update({ id: readUsers[0].id }) | ||
.getOne({ | ||
.returnOne({ | ||
name: 'Every User 2', | ||
}); | ||
expect(update).toEqual({ id: 1 }); | ||
const readUser2 = yield userMapperReturningID.select('id', '=', 1).getOne(); | ||
const readUser2 = yield userMapperReturningID | ||
.select('id', '=', 1) | ||
.returnOne(); | ||
expect(readUser2 === null || readUser2 === void 0 ? void 0 : readUser2.name).toEqual('Every User 2'); | ||
@@ -107,3 +111,5 @@ const updateCount = yield userMapperReturningID.update().getCount({ | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[0]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(test_objects_1.USERS[1]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.returnOne(test_objects_1.USERS[1]); | ||
yield userMapperReturningID.insert().run(test_objects_1.USERS[2]); | ||
@@ -114,7 +120,7 @@ // Verify that update performs the correct change on the correct row. | ||
.update({ id: insertReturn.id }) | ||
.getAll(updateValues1); | ||
.returnAll(updateValues1); | ||
expect(updateReturns1).toEqual([{ id: insertReturn.id }]); | ||
let readUser = yield userMapperReturningID | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.email).toEqual(updateValues1.email); | ||
@@ -125,3 +131,3 @@ // Verify a different change on the same row, returning multiple columns. | ||
.update({ email: updateValues1.email }) | ||
.getAll(updateValues2); | ||
.returnAll(updateValues2); | ||
updateReturns2[0].id; // ensure key is accessible | ||
@@ -137,3 +143,3 @@ updateReturns2[0].h; // ensure key is accessible | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.name).toEqual(updateValues2.name); | ||
@@ -144,3 +150,3 @@ // Verify that update changes all required rows. | ||
.update({ name: 'Sue' }) | ||
.getAll(updateValues3); | ||
.returnAll(updateValues3); | ||
expect(updateReturns3.length).toEqual(3); | ||
@@ -152,3 +158,3 @@ expect(updateReturns3[0].h).toEqual(test_objects_1.USERS[0].handle); | ||
.select('name', '=', updateValues3.name) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -166,3 +172,3 @@ (0, test_utils_1.ignore)('check return types', () => { | ||
.update({ name: 'Sue' }) | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
.returnAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -173,3 +179,3 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -181,3 +187,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
.returnAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -188,11 +194,11 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningAll | ||
.update({ name: 'Sue' }) | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
const expectedUsers = [ | ||
@@ -205,7 +211,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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningIDAndHandleAsH | ||
.update() | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
const expectedUsers = test_objects_1.USERS.map((user, i) => ({ | ||
@@ -216,3 +222,3 @@ id: insertReturns[i].id, | ||
expect(updateReturns).toEqual(expectedUsers); | ||
const readUsers = yield userMapperReturningID.select().getAll(); | ||
const readUsers = yield userMapperReturningID.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -224,3 +230,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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -233,3 +239,3 @@ const updateCount = yield userMapperReturningAll | ||
.select('id', '>', insertReturns[0].id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -241,3 +247,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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -250,3 +256,3 @@ const updateCount = yield userMapperReturningDefault | ||
.select('id', '>', insertReturns[0].id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -258,3 +264,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().getAll(test_objects_1.USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(test_objects_1.USERS); | ||
const updateValues1 = { email: 'foo@xyz.pdq' }; | ||
@@ -274,3 +280,3 @@ const updateCount = yield userMapperReturningAll | ||
])) | ||
.getAll(updateValues2); | ||
.returnAll(updateValues2); | ||
expect(updateReturns).toEqual([ | ||
@@ -291,9 +297,9 @@ { id: insertReturns[0].id }, | ||
{ notThere: 'xyz' }) | ||
.getAll({ email: 'abc@def.ghi' }); | ||
.returnAll({ email: 'abc@def.ghi' }); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update('notThere', '=', 'foo').getAll({ | ||
userMapperReturningID.update('notThere', '=', 'foo').returnAll({ | ||
email: 'abc@def.ghi', | ||
}); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update('notThere', '=', 'foo').getAll({ | ||
userMapperReturningID.update('notThere', '=', 'foo').returnAll({ | ||
email: 'abc@def.ghi', | ||
@@ -304,4 +310,4 @@ }); | ||
// @ts-expect-error - update must only have table columns | ||
.getAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getAll( | ||
.returnAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).returnAll( | ||
// @ts-expect-error - update must only have table columns | ||
@@ -311,6 +317,6 @@ { notThere: 'xyz@pdq.xyz' }); | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(test_objects_1.USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).returnAll(test_objects_1.USERS[0]))[0].name; | ||
// @ts-expect-error - only requested columns are accessible | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(test_objects_1.USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).returnAll(test_objects_1.USERS[0]))[0].name; | ||
yield userMapperReturningID | ||
@@ -325,3 +331,3 @@ .update(({ or, cmpr }) => | ||
or([cmpr('notThere', '=', 'xyz'), cmpr('alsoNotThere', '=', 'Sue')])) | ||
.getAll(test_objects_1.USERS[0]); | ||
.returnAll(test_objects_1.USERS[0]); | ||
// @ts-expect-error - ID filter must have correct type | ||
@@ -354,3 +360,3 @@ userMapperReturningID.update('str'); | ||
.insert() | ||
.getAll([test_objects_1.userRow1, test_objects_1.userRow2, test_objects_1.userRow3]); | ||
.returnAll([test_objects_1.userRow1, test_objects_1.userRow2, test_objects_1.userRow3]); | ||
const updatingUser1 = test_types_1.UpdatingUser.create(0, Object.assign({}, test_objects_1.userObject1, { firstName: 'Suzanne' })); | ||
@@ -362,3 +368,3 @@ const updateReturns = yield mapper | ||
])) | ||
.getAll(updatingUser1); | ||
.returnAll(updatingUser1); | ||
expect(updateReturns).toEqual([ | ||
@@ -371,3 +377,3 @@ { id: insertReturns[0].id }, | ||
.modify((qb) => qb.orderBy('id')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers).toEqual([ | ||
@@ -397,6 +403,6 @@ Object.assign({}, test_objects_1.userRow1, { | ||
.insert() | ||
.getOne(test_objects_1.userRow1); | ||
.returnOne(test_objects_1.userRow1); | ||
const updateReturn = yield updateReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getAll({ name: 'Suzanne Smith' }); | ||
.returnAll({ name: 'Suzanne Smith' }); | ||
expect(updateReturn).toEqual([ | ||
@@ -423,6 +429,6 @@ new test_types_1.ReturnedUser(insertReturn.id, 'Suzanne', 'Smith', '(handle)', '(email)'), | ||
.insert() | ||
.getOne(test_objects_1.userRow1); | ||
.returnOne(test_objects_1.userRow1); | ||
const updateReturn = yield updateAndReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getAll(test_types_1.UpdatingUser.create(0, test_objects_1.userObject1)); | ||
.returnAll(test_types_1.UpdatingUser.create(0, test_objects_1.userObject1)); | ||
expect(updateReturn).toEqual([ | ||
@@ -429,0 +435,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), |
@@ -33,7 +33,9 @@ "use strict"; | ||
const userWithID = new MappedUser(1, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email); | ||
const updateReturn1 = yield userMapper.update({ id: 1 }).getOne(userWithID); | ||
const updateReturn1 = yield userMapper | ||
.update({ id: 1 }) | ||
.returnOne(userWithID); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user with falsy id | ||
const insertedUser1 = new MappedUser(0, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email); | ||
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1)); | ||
const insertReturn1 = (yield userMapper.insert().returnOne(insertedUser1)); | ||
expect(insertReturn1).not.toBeNull(); | ||
@@ -45,3 +47,3 @@ expect(insertReturn1.id).toBeGreaterThan(0); | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser1).toEqual(Object.assign(Object.assign({}, insertedUser1), { id: insertReturn1.id })); | ||
@@ -53,3 +55,3 @@ // ensure 'id' is accessible | ||
const insertedUser2 = new MappedUser(10, test_objects_1.USERS[1].name, test_objects_1.USERS[1].handle, test_objects_1.USERS[1].email); | ||
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2)); | ||
const insertReturn2 = (yield userMapper.insert().returnOne(insertedUser2)); | ||
expect(insertReturn2).toEqual(insertedUser2); | ||
@@ -59,3 +61,3 @@ insertReturn2 === null || insertReturn2 === void 0 ? void 0 : insertReturn2.name; // ensure 'name' is accessible | ||
.select({ id: insertReturn2.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser2).toEqual(insertedUser2); | ||
@@ -66,3 +68,3 @@ // test updating a user, with returned object | ||
.update({ id: updatingUser.id }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.name; // ensure 'name' is accessible | ||
@@ -72,3 +74,3 @@ expect(updateReturn).toEqual(updatingUser); | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toEqual(updatingUser); | ||
@@ -83,9 +85,13 @@ // test updating a user, without returned object | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4).toEqual(updatingUser2); | ||
// test updating multiple users returning select columns | ||
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' }); | ||
const updateReturn3 = yield userMapper | ||
.update() | ||
.returnAll({ name: 'Everyone' }); | ||
expect(updateReturn3).toEqual([{ id: 1 }, { id: 10 }]); | ||
updateReturn3[0].id; // ensure 'id' is accessible | ||
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' }); | ||
const updateReturn4 = yield userMapper | ||
.update() | ||
.returnOne({ name: 'Everyone' }); | ||
expect(updateReturn4).toEqual({ id: 1 }); | ||
@@ -98,3 +104,3 @@ updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser5).toBeNull(); | ||
@@ -144,7 +150,7 @@ })); | ||
.update({ id: 1 }) | ||
.getOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email)); | ||
.returnOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email)); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user | ||
const insertedUser = new MappedUser(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().getOne(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().returnOne(insertedUser)); | ||
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -156,3 +162,3 @@ expect(insertReturn).not.toBeNull(); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible | ||
@@ -165,3 +171,3 @@ expect(selectedUser1).toEqual(insertReturn); | ||
.update({ id: updatingUser.serialNo }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn2 === null || updateReturn2 === void 0 ? void 0 : updateReturn2.firstName; // ensure 'firstName' is accessible | ||
@@ -171,3 +177,3 @@ expect(updateReturn2).toEqual(updatingUser); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.firstName; // ensure 'firstName' is accessible | ||
@@ -179,3 +185,3 @@ expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.serialNo).toEqual(selectedUser1.serialNo); | ||
.update('id', '=', insertReturn.serialNo) | ||
.getAll({ | ||
.returnAll({ | ||
name: 'Foo Foo', | ||
@@ -187,9 +193,13 @@ }); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4 === null || selectedUser4 === void 0 ? void 0 : selectedUser4.firstName).toEqual('Foo'); | ||
// test updating multiple users returning select columns | ||
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' }); | ||
const updateReturn3 = yield userMapper | ||
.update() | ||
.returnAll({ name: 'Everyone' }); | ||
expect(updateReturn3).toEqual([{ id: 1 }]); | ||
updateReturn3[0].id; // ensure 'id' is accessible | ||
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' }); | ||
const updateReturn4 = yield userMapper | ||
.update() | ||
.returnOne({ name: 'Everyone' }); | ||
expect(updateReturn4).toEqual({ id: 1 }); | ||
@@ -202,3 +212,3 @@ updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toBeNull(); | ||
@@ -232,7 +242,7 @@ })); | ||
.update({ id: 1 }) | ||
.getOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email)); | ||
.returnOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email)); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user | ||
const insertedUser = new MappedUser(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().getOne(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().returnOne(insertedUser)); | ||
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -244,3 +254,3 @@ expect(insertReturn).not.toBeNull(); | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible | ||
@@ -253,3 +263,3 @@ expect(selectedUser1).toEqual(insertReturn); | ||
.update({ id: updatingUser.id }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -259,3 +269,3 @@ expect(updateReturn).toEqual(updatingUser); | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser2).toEqual(updatingUser); | ||
@@ -270,3 +280,3 @@ // test updating a user, without returned object | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toEqual(updatingUser2); | ||
@@ -278,3 +288,3 @@ // test deleting a user | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4).toBeNull(); | ||
@@ -298,3 +308,3 @@ })); | ||
test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email); | ||
const insertReturn = yield userMapper.insert().getOne(insertedUser); | ||
const insertReturn = yield userMapper.insert().returnOne(insertedUser); | ||
expect(insertReturn).toBeUndefined(); | ||
@@ -304,5 +314,5 @@ // test getting a user by ID | ||
.select({ id: insertedUser.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser1).toEqual(insertedUser); | ||
})); | ||
//# sourceMappingURL=UniformTableMapper.test.js.map |
@@ -38,3 +38,3 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selection, Insertable } from 'kysely'; | ||
*/ | ||
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
returnAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
/** | ||
@@ -50,3 +50,3 @@ * Inserts the provided object into the table as a row, first transforming | ||
*/ | ||
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>; | ||
returnOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>; | ||
/** | ||
@@ -53,0 +53,0 @@ * Runs the query, inserting rows into the table without returning any columns. |
@@ -50,3 +50,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
getAll(objs) { | ||
returnAll(objs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -66,3 +66,3 @@ if (this.returnColumns.length === 0) { | ||
} | ||
getOne(obj) { | ||
returnOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -69,0 +69,0 @@ if (this.returnColumns.length === 0) { |
@@ -20,3 +20,3 @@ import { Compilable, Kysely } from 'kysely'; | ||
*/ | ||
getAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
returnAll<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject[]>; | ||
/** | ||
@@ -30,4 +30,4 @@ * Executes the query with all parameters replaced, returning the first | ||
*/ | ||
getOne<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject | null>; | ||
returnOne<DB>(db: Kysely<DB>, params: P): Promise<SelectedObject | null>; | ||
} | ||
//# sourceMappingURL=paramed-row-query.d.ts.map |
@@ -42,3 +42,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
*/ | ||
getAll(db, params) { | ||
returnAll(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -57,3 +57,3 @@ const results = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").execute(db, params); | ||
*/ | ||
getOne(db, params) { | ||
returnOne(db, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -60,0 +60,0 @@ const result = yield __classPrivateFieldGet(this, _ParameterizedRowQuery_parameterizedQuery, "f").executeTakeFirst(db, params); |
@@ -22,3 +22,3 @@ import { Kysely, SelectQueryBuilder } from 'kysely'; | ||
*/ | ||
getAll(): Promise<SelectedObject[]>; | ||
returnAll(): Promise<SelectedObject[]>; | ||
/** | ||
@@ -29,3 +29,3 @@ * Retrieves a single row from the table, using `selectTransform` | ||
*/ | ||
getOne(): Promise<SelectedObject | null>; | ||
returnOne(): Promise<SelectedObject | null>; | ||
/** | ||
@@ -32,0 +32,0 @@ * Modifies the underlying Kysely query builder. All columns given in |
@@ -30,3 +30,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
*/ | ||
getAll() { | ||
returnAll() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -44,3 +44,3 @@ const results = yield this.qb.execute(); | ||
*/ | ||
getOne() { | ||
returnOne() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -47,0 +47,0 @@ const result = yield this.qb.executeTakeFirst(); |
@@ -49,4 +49,4 @@ import { Kysely, Selection, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely'; | ||
*/ | ||
getAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
getAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>; | ||
returnAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>; | ||
returnAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>; | ||
/** | ||
@@ -64,4 +64,4 @@ * Updates rows with the values that result from transforming the object via | ||
*/ | ||
getOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>; | ||
getOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>; | ||
returnOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>; | ||
returnOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>; | ||
/** | ||
@@ -68,0 +68,0 @@ * Runs the query, updating rows, without returning any columns. |
@@ -64,3 +64,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
getAll(obj) { | ||
returnAll(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -80,3 +80,3 @@ if (this.returnColumns.length === 0) { | ||
} | ||
getOne(obj) { | ||
returnOne(obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -83,0 +83,0 @@ if (this.returnColumns.length === 0) { |
@@ -39,3 +39,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
expect(success).toBe(true); | ||
const users = yield testMapper.select().getAll(); | ||
const users = yield testMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -55,3 +55,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count2).toEqual(BigInt(2)); | ||
const users = yield defaultMapper.select().getAll(); | ||
const users = yield defaultMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -74,3 +74,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count2).toEqual(2); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -83,3 +83,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count1).toEqual(3); | ||
const users1 = yield userMapper.select().getAll(); | ||
const users1 = yield userMapper.select().returnAll(); | ||
expect(users1.length).toEqual(0); | ||
@@ -89,3 +89,3 @@ yield userMapper.insert().run(USERS); | ||
expect(success).toBe(true); | ||
const users2 = yield userMapper.select().getAll(); | ||
const users2 = yield userMapper.select().returnAll(); | ||
expect(users2.length).toEqual(0); | ||
@@ -116,3 +116,3 @@ })); | ||
expect(count1).toEqual(2); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -134,3 +134,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
expect(count2).toEqual(1); | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -153,3 +153,3 @@ })); | ||
// expect(count2).toEqual(2); | ||
// const users = await userMapper.select().getAll(); | ||
// const users = await userMapper.select().returnAll(); | ||
// expect(users.length).toEqual(1); | ||
@@ -161,3 +161,3 @@ // expect(users[0].handle).toEqual(USERS[1].handle); | ||
// expect(count3).toEqual(1); | ||
// const users2 = await userMapper.select().getAll(); | ||
// const users2 = await userMapper.select().returnAll(); | ||
// expect(users2.length).toEqual(0); | ||
@@ -164,0 +164,0 @@ // ignore('parameterization type errors', () => { |
@@ -67,3 +67,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
expect(success).toBe(true); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -80,6 +80,6 @@ for (let i = 0; i < USERS.length; i++) { | ||
})); | ||
it('inserts multiple via getAll() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getAll(USERS); | ||
it('inserts multiple via returnAll() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().returnAll(USERS); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -96,6 +96,8 @@ for (let i = 0; i < USERS.length; i++) { | ||
})); | ||
it('inserts multiple via getOne() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault.insert().getOne(USERS[0]); | ||
it('inserts multiple via returnOne() without returning columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const results = yield userMapperReturningDefault | ||
.insert() | ||
.returnOne(USERS[0]); | ||
expect(results).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(1); | ||
@@ -111,3 +113,3 @@ expect(readUsers[0].handle).toEqual(USERS[0].handle); | ||
it('inserts multiple returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturns = yield userMapperReturningID.insert().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
expect(insertReturns.length).toEqual(3); | ||
@@ -118,3 +120,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
} | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -129,3 +131,3 @@ for (let i = 0; i < USERS.length; i++) { | ||
.insert() | ||
.getAll([post0, post1, post2]); | ||
.returnAll([post0, post1, post2]); | ||
expect(updateReturns.length).toEqual(3); | ||
@@ -147,5 +149,5 @@ for (let i = 0; i < updateReturns.length; i++) { | ||
.insert() | ||
.getAll(USERS); | ||
.returnAll(USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -159,5 +161,5 @@ for (let i = 0; i < USERS.length; i++) { | ||
.insert() | ||
.getAll(USERS); | ||
.returnAll(USERS); | ||
expect(insertReturns).toBeUndefined(); | ||
const readUsers = yield userMapperReturningAll.select().getAll(); | ||
const readUsers = yield userMapperReturningAll.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -169,3 +171,5 @@ 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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningAll | ||
.insert() | ||
.returnAll(USERS); | ||
for (let i = 0; i < USERS.length; i++) { | ||
@@ -178,11 +182,11 @@ expect(insertReturns[i].id).toBeGreaterThan(0); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getAll([{}]); | ||
userMapperReturningAll.insert().returnAll([{}]); | ||
// @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().getAll([{ email: 'xyz@pdq.xyz' }]); | ||
userMapperReturningAll.insert().returnAll([{ 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().getAll([USERS[0]]))[0].handle; | ||
(yield userMapperReturningID.insert().returnAll([USERS[0]]))[0].handle; | ||
// @ts-expect-error - only configured columns are returned | ||
@@ -198,3 +202,3 @@ (yield userMapperReturningID.insert().run([USERS[0]]))[0].handle; | ||
.select('email', '=', USERS[0].email) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(USERS[0].email); | ||
@@ -207,7 +211,9 @@ })); | ||
.select('email', '=', USERS[0].email) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(USERS[0].email); | ||
})); | ||
it('inserts one returning configured return columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningID.insert().getOne(USERS[0]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.returnOne(USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -217,3 +223,3 @@ expect(Object.keys(insertReturn).length).toEqual(1); | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser0 === null || readUser0 === void 0 ? void 0 : readUser0.email).toEqual(USERS[0].email); | ||
@@ -223,3 +229,3 @@ const post0 = Object.assign({}, POSTS[0], { userId: insertReturn.id }); | ||
.insert() | ||
.getOne(post0); | ||
.returnOne(post0); | ||
expect(updateReturn.id).toBeGreaterThan(0); | ||
@@ -233,3 +239,3 @@ expect(updateReturn.t).toEqual(POSTS[0].title); | ||
])) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readPost0 === null || readPost0 === void 0 ? void 0 : readPost0.likeCount).toEqual(post0.likeCount); | ||
@@ -244,3 +250,5 @@ ignore('check return types', () => { | ||
it('inserts one configured to return all columns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const insertReturn = yield userMapperReturningAll.insert().getOne(USERS[0]); | ||
const insertReturn = yield userMapperReturningAll | ||
.insert() | ||
.returnOne(USERS[0]); | ||
expect(insertReturn.id).toBeGreaterThan(0); | ||
@@ -252,11 +260,11 @@ const expectedUser = Object.assign({}, USERS[0], { id: insertReturn.id }); | ||
// @ts-expect-error - inserted object must have all required columns | ||
userMapperReturningAll.insert().getOne({}); | ||
userMapperReturningAll.insert().returnOne({}); | ||
// @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().getOne({ email: 'xyz@pdq.xyz' }); | ||
userMapperReturningAll.insert().returnOne({ 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().getOne(USERS[0])).name; | ||
(yield userMapperReturningID.insert().returnOne(USERS[0])).name; | ||
// @ts-expect-error - only requested columns are returned | ||
@@ -284,3 +292,3 @@ (yield userMapperReturningDefault.insert().run(USERS[0])).name; | ||
.insert() | ||
.getOne(insertedUser1); | ||
.returnOne(insertedUser1); | ||
const readUser1 = yield insertTransformMapper | ||
@@ -290,8 +298,10 @@ .select({ | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.name).toEqual(`${insertedUser1.firstName} ${insertedUser1.lastName}`); | ||
yield insertTransformMapper.insert().getAll([insertedUser2, insertedUser3]); | ||
yield insertTransformMapper | ||
.insert() | ||
.returnAll([insertedUser2, insertedUser3]); | ||
const readUsers = yield insertTransformMapper | ||
.select('id', '>', insertReturn.id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -314,7 +324,7 @@ expect(readUsers[0].name).toEqual(`${insertedUser2.firstName} ${insertedUser2.lastName}`); | ||
.insert() | ||
.getOne(userRow1); | ||
.returnOne(userRow1); | ||
expect(insertReturn).toEqual(insertReturnedUser1); | ||
const insertReturns = yield insertReturnTransformMapper | ||
.insert() | ||
.getAll([userRow2, userRow3]); | ||
.returnAll([userRow2, userRow3]); | ||
expect(insertReturns).toEqual([insertReturnedUser2, insertReturnedUser3]); | ||
@@ -340,7 +350,7 @@ })); | ||
.insert() | ||
.getOne(insertedUser1); | ||
.returnOne(insertedUser1); | ||
expect(insertReturn).toEqual(insertReturnedUser1); | ||
const insertReturns = yield insertAndReturnTransformMapper | ||
.insert() | ||
.getAll([insertedUser2, insertedUser3]); | ||
.returnAll([insertedUser2, insertedUser3]); | ||
expect(insertReturns).toEqual([insertReturnedUser2, insertReturnedUser3]); | ||
@@ -351,7 +361,7 @@ })); | ||
// @ts-expect-error - requires InsertedObject as input | ||
yield insertTransformMapper.insert().getOne(USERS[0]); | ||
yield insertTransformMapper.insert().returnOne(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().getOne(selectedUser1); | ||
yield insertTransformMapper.insert().returnOne(selectedUser1); | ||
// @ts-expect-error - requires InsertedObject as input | ||
@@ -358,0 +368,0 @@ yield insertTransformMapper.insert().run(selectedUser1); |
@@ -87,3 +87,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
// @ts-expect-error - ensure that return type is User | ||
.getOne(new User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name; | ||
.returnOne(new User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name; | ||
})); | ||
@@ -90,0 +90,0 @@ it('dummy test', () => { |
@@ -41,3 +41,3 @@ /** | ||
// ); | ||
// const users = await parameterization.getAll(db, { | ||
// const users = await parameterization.returnAll(db, { | ||
// name: USERS[0].name, | ||
@@ -50,3 +50,3 @@ // }); | ||
// ((_: string) => {})(users[0].handle); | ||
// const user = await parameterization.getOne(db, { | ||
// const user = await parameterization.returnOne(db, { | ||
// name: USERS[0].name, | ||
@@ -59,3 +59,3 @@ // }); | ||
// // @ts-expect-error - errors on invalid parameter names | ||
// parameterization.getAll(db, { notThere: 'foo' }); | ||
// parameterization.returnAll(db, { notThere: 'foo' }); | ||
// // @ts-expect-error - errors on invalid column names | ||
@@ -72,3 +72,3 @@ // users[0].notThere; | ||
.modify((qb) => qb.where('name', '=', USERS[0].name).orderBy('handle', 'desc')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -80,3 +80,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
.modify((qb) => qb.where('name', '=', USERS[0].name).orderBy('handle', 'desc')) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[2].handle); | ||
@@ -89,3 +89,3 @@ })); | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users).toEqual([ | ||
@@ -104,3 +104,3 @@ Object.assign(Object.assign({}, USERS[2]), { id: 3 }), | ||
.modify((qb) => qb.select('name').orderBy('handle', 'desc')) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user).toEqual(Object.assign(Object.assign({}, USERS[2]), { id: 3 })); | ||
@@ -124,3 +124,3 @@ // Ensure that columns can be addressed by name. | ||
yield mapper.insert().run(USERS); | ||
const users = yield mapper.select([3, 'Sue']).getAll(); | ||
const users = yield mapper.select([3, 'Sue']).returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -146,3 +146,3 @@ expect(users[0].name).toEqual(USERS[2].name); | ||
yield mapper.insert().run(USERS); | ||
const users = yield mapper.select(['Sue', 3]).getAll(); | ||
const users = yield mapper.select(['Sue', 3]).returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -185,6 +185,6 @@ expect(users[0].name).toEqual(USERS[2].name); | ||
}); | ||
describe('select() getAll()', () => { | ||
describe('select() returnAll()', () => { | ||
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' }).getAll(); | ||
const users = yield userMapper.select({ name: 'Not There' }).returnAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -195,3 +195,3 @@ })); | ||
// Test selecting all | ||
const users = yield userMapper.select().getAll(); | ||
const users = yield userMapper.select().returnAll(); | ||
expect(users.length).toEqual(USERS.length); | ||
@@ -205,7 +205,7 @@ for (let i = 0; i < USERS.length; i++) { | ||
// Test selecting via key value | ||
const users1 = yield userMapper.select(2).getAll(); | ||
const users1 = yield userMapper.select(2).returnAll(); | ||
expect(users1.length).toEqual(1); | ||
expect(users1[0].handle).toEqual(USERS[1].handle); | ||
// Test selecting via key tuple | ||
const users2 = yield userMapper.select([2]).getAll(); | ||
const users2 = yield userMapper.select([2]).returnAll(); | ||
expect(users2.length).toEqual(1); | ||
@@ -220,3 +220,3 @@ expect(users2[0].handle).toEqual(USERS[1].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -230,3 +230,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -238,3 +238,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select('name', '=', USERS[0].name).getAll(); | ||
let users = yield userMapper.select('name', '=', USERS[0].name).returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -244,3 +244,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select('name', '=', 'nonexistent').getAll(); | ||
users = yield userMapper.select('name', '=', 'nonexistent').returnAll(); | ||
expect(users.length).toEqual(0); | ||
@@ -252,3 +252,3 @@ })); | ||
.select(sql `name != ${USERS[0].name}`) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -263,3 +263,3 @@ expect(users[0].handle).toEqual(USERS[1].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -273,3 +273,3 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(users.length).toEqual(1); | ||
@@ -281,3 +281,3 @@ expect(users[0].handle).toEqual(USERS[2].handle); | ||
// Test selecting by condition (with results) | ||
let users = yield userMapper.select('name', '=', USERS[0].name).getAll(); | ||
let users = yield userMapper.select('name', '=', USERS[0].name).returnAll(); | ||
expect(users.length).toEqual(2); | ||
@@ -287,7 +287,7 @@ expect(users[0].handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no results) | ||
users = yield userMapper.select('name', '=', 'nonexistent').getAll(); | ||
users = yield userMapper.select('name', '=', 'nonexistent').returnAll(); | ||
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().getAll(USERS); | ||
const ids = yield userMapper.insert().returnAll(USERS); | ||
const mapper = new TableMapper(db, 'users', { | ||
@@ -297,4 +297,4 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getAll())[0].h; | ||
const users = yield mapper.select({ name: USERS[0].name }).getAll(); | ||
(yield mapper.select().returnAll())[0].h; | ||
const users = yield mapper.select({ name: USERS[0].name }).returnAll(); | ||
expect(users).toEqual([ | ||
@@ -314,20 +314,20 @@ { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getAll())[0].name; | ||
(yield mapper.select().returnAll())[0].name; | ||
})); | ||
})); | ||
ignore('detects select() getAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
ignore('detects select() returnAll() simple filter type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select().getAll())[0].notThere; | ||
(yield userMapper.select().returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getAll())[0].notThere; | ||
(yield userMapper.select({}).returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
// prettier-ignore | ||
(yield userMapper.select({ name: "Sue" }).getAll())[0].notThere; | ||
(yield userMapper.select({ name: "Sue" }).returnAll())[0].notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select("name", "=", "Sue").getAll())[0].notThere; | ||
(yield userMapper.select("name", "=", "Sue").returnAll())[0].notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getAll() | ||
.returnAll() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -338,3 +338,3 @@ )[0].notThere; | ||
.select(sql `name = 'Sue'`) | ||
.getAll() | ||
.returnAll() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -344,8 +344,8 @@ )[0].notThere; | ||
}); | ||
describe('select() getOne()', () => { | ||
describe('select() returnOne()', () => { | ||
it('selects the first row with no filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield userMapper.insert().run(USERS); | ||
let user = yield userMapper.select().getOne(); | ||
let user = yield userMapper.select().returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
user = yield userMapper.select({}).getOne(); | ||
user = yield userMapper.select({}).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
@@ -355,3 +355,3 @@ })); | ||
yield userMapper.insert().run(USERS); | ||
let user = yield userMapper.select({ name: USERS[0].name }).getOne(); | ||
let user = yield userMapper.select({ name: USERS[0].name }).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
@@ -363,3 +363,3 @@ user = yield userMapper | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[2].handle); | ||
@@ -370,6 +370,6 @@ })); | ||
// Test selecting by condition (with result) | ||
let user = yield userMapper.select('name', '=', USERS[0].name).getOne(); | ||
let user = yield userMapper.select('name', '=', USERS[0].name).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no result) | ||
user = yield userMapper.select('name', '=', 'nonexistent').getOne(); | ||
user = yield userMapper.select('name', '=', 'nonexistent').returnOne(); | ||
expect(user).toBeNull(); | ||
@@ -381,10 +381,10 @@ })); | ||
.select(sql `name != ${USERS[0].name}`) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[1].handle); | ||
})); | ||
it('selects the first row with a compound filter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const userIDs = yield userMapper.insert().getAll(USERS); | ||
const userIDs = yield userMapper.insert().returnAll(USERS); | ||
const user = yield userMapper | ||
.select(({ and, cmpr }) => and([cmpr('name', '=', USERS[0].name), cmpr('id', '>', userIDs[0].id)])) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[2].handle); | ||
@@ -394,3 +394,3 @@ })); | ||
yield userMapper.insert().run(USERS); | ||
let user = yield userMapper.select({ name: USERS[0].name }).getOne(); | ||
let user = yield userMapper.select({ name: USERS[0].name }).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
@@ -402,3 +402,3 @@ user = yield userMapper | ||
}) | ||
.getOne(); | ||
.returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[2].handle); | ||
@@ -409,10 +409,10 @@ })); | ||
// Test selecting by condition (with result) | ||
let user = yield userMapper.select('name', '=', USERS[0].name).getOne(); | ||
let user = yield userMapper.select('name', '=', USERS[0].name).returnOne(); | ||
expect(user === null || user === void 0 ? void 0 : user.handle).toEqual(USERS[0].handle); | ||
// Test selecting by condition (no result) | ||
user = yield userMapper.select('name', '=', 'nonexistent').getOne(); | ||
user = yield userMapper.select('name', '=', 'nonexistent').returnOne(); | ||
expect(user).toBeNull(); | ||
})); | ||
it('selects one returning selected columns and aliases', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ids = yield userMapper.insert().getAll(USERS); | ||
const ids = yield userMapper.insert().returnAll(USERS); | ||
const mapper = new TableMapper(db, 'users', { | ||
@@ -422,22 +422,22 @@ selectedColumns: ['id', 'handle as h'], | ||
// Should allow access to aliased columns | ||
(yield mapper.select().getOne()).h; | ||
const user = yield mapper.select({ handle: USERS[0].handle }).getOne(); | ||
(yield mapper.select().returnOne()).h; | ||
const user = yield mapper.select({ handle: USERS[0].handle }).returnOne(); | ||
expect(user).toEqual({ id: ids[0].id, h: USERS[0].handle }); | ||
ignore('inaccessible types are not allowed', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - unselected columns are not allowed | ||
(yield mapper.select().getAll())[0].name; | ||
(yield mapper.select().returnAll())[0].name; | ||
})); | ||
})); | ||
ignore('detects select() getOne() type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
ignore('detects select() returnOne() type errors', () => __awaiter(void 0, void 0, void 0, function* () { | ||
// @ts-expect-error - only table columns are accessible unfiltered | ||
(yield userMapper.select({}).getOne()).notThere; | ||
(yield userMapper.select({}).returnOne()).notThere; | ||
// @ts-expect-error - only table columns are accessible w/ object filter | ||
(yield userMapper.select({ name: 'Sue' }).getOne()).notThere; | ||
(yield userMapper.select({ name: 'Sue' }).returnOne()).notThere; | ||
// @ts-expect-error - only table columns are accessible w/ op filter | ||
// prettier-ignore | ||
(yield userMapper.select("name", "=", "Sue").getOne()).notThere; | ||
(yield userMapper.select("name", "=", "Sue").returnOne()).notThere; | ||
// prettier-ignore | ||
(yield userMapper | ||
.select((qb) => qb) | ||
.getOne() | ||
.returnOne() | ||
// @ts-expect-error - only table columns are accessible w/ QB filter | ||
@@ -448,3 +448,3 @@ ).notThere; | ||
.select(sql `name = 'Sue'`) | ||
.getOne() | ||
.returnOne() | ||
// @ts-expect-error - only table columns are accessible w/ expr filter | ||
@@ -451,0 +451,0 @@ ).notThere; |
@@ -47,7 +47,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
.update({ id: 1 }) | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
expect(updates.length).toEqual(0); | ||
const update = yield userMapperReturningID | ||
.update({ id: 1 }) | ||
.getOne(updateValues); | ||
.returnOne(updateValues); | ||
expect(update).toBeNull(); | ||
@@ -57,3 +57,5 @@ })); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const insertReturn0 = yield userMapperReturningID.insert().getOne(USERS[0]); | ||
const insertReturn0 = yield userMapperReturningID | ||
.insert() | ||
.returnOne(USERS[0]); | ||
yield userMapperReturningID.insert().run(USERS[1]); | ||
@@ -67,3 +69,3 @@ yield userMapperReturningID.insert().run(USERS[2]); | ||
.select('id', '=', insertReturn0.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser1 === null || readUser1 === void 0 ? void 0 : readUser1.email).toEqual(updateValues.email); | ||
@@ -76,7 +78,7 @@ const updateCount2 = yield userMapperReturningAll | ||
.select('name', '=', 'Sue') | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
expect(readUsers[0].email).toEqual(updateValues.email); | ||
expect(readUsers[1].email).toEqual(updateValues.email); | ||
const updates = yield userMapperReturningID.update().getAll({ | ||
const updates = yield userMapperReturningID.update().returnAll({ | ||
name: 'Every User 1', | ||
@@ -87,7 +89,9 @@ }); | ||
.update({ id: readUsers[0].id }) | ||
.getOne({ | ||
.returnOne({ | ||
name: 'Every User 2', | ||
}); | ||
expect(update).toEqual({ id: 1 }); | ||
const readUser2 = yield userMapperReturningID.select('id', '=', 1).getOne(); | ||
const readUser2 = yield userMapperReturningID | ||
.select('id', '=', 1) | ||
.returnOne(); | ||
expect(readUser2 === null || readUser2 === void 0 ? void 0 : readUser2.name).toEqual('Every User 2'); | ||
@@ -105,3 +109,5 @@ const updateCount = yield userMapperReturningID.update().getCount({ | ||
yield userMapperReturningID.insert().run(USERS[0]); | ||
const insertReturn = yield userMapperReturningID.insert().getOne(USERS[1]); | ||
const insertReturn = yield userMapperReturningID | ||
.insert() | ||
.returnOne(USERS[1]); | ||
yield userMapperReturningID.insert().run(USERS[2]); | ||
@@ -112,7 +118,7 @@ // Verify that update performs the correct change on the correct row. | ||
.update({ id: insertReturn.id }) | ||
.getAll(updateValues1); | ||
.returnAll(updateValues1); | ||
expect(updateReturns1).toEqual([{ id: insertReturn.id }]); | ||
let readUser = yield userMapperReturningID | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.email).toEqual(updateValues1.email); | ||
@@ -123,3 +129,3 @@ // Verify a different change on the same row, returning multiple columns. | ||
.update({ email: updateValues1.email }) | ||
.getAll(updateValues2); | ||
.returnAll(updateValues2); | ||
updateReturns2[0].id; // ensure key is accessible | ||
@@ -135,3 +141,3 @@ updateReturns2[0].h; // ensure key is accessible | ||
.select('id', '=', insertReturn.id) | ||
.getOne(); | ||
.returnOne(); | ||
expect(readUser === null || readUser === void 0 ? void 0 : readUser.name).toEqual(updateValues2.name); | ||
@@ -142,3 +148,3 @@ // Verify that update changes all required rows. | ||
.update({ name: 'Sue' }) | ||
.getAll(updateValues3); | ||
.returnAll(updateValues3); | ||
expect(updateReturns3.length).toEqual(3); | ||
@@ -150,3 +156,3 @@ expect(updateReturns3[0].h).toEqual(USERS[0].handle); | ||
.select('name', '=', updateValues3.name) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -164,3 +170,3 @@ ignore('check return types', () => { | ||
.update({ name: 'Sue' }) | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
.returnAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -171,3 +177,3 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -179,3 +185,3 @@ })); | ||
.update({ name: 'Sue' }) | ||
.getAll({ email: 'new.email@xyz.pdq' }); | ||
.returnAll({ email: 'new.email@xyz.pdq' }); | ||
expect(updates).toBeUndefined(); | ||
@@ -186,11 +192,11 @@ const readUsers = yield userMapperReturningID | ||
}) | ||
.getAll(); | ||
.returnAll(); | ||
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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningAll | ||
.update({ name: 'Sue' }) | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
const expectedUsers = [ | ||
@@ -203,7 +209,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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
const updateReturns = yield userMapperReturningIDAndHandleAsH | ||
.update() | ||
.getAll(updateValues); | ||
.returnAll(updateValues); | ||
const expectedUsers = USERS.map((user, i) => ({ | ||
@@ -214,3 +220,3 @@ id: insertReturns[i].id, | ||
expect(updateReturns).toEqual(expectedUsers); | ||
const readUsers = yield userMapperReturningID.select().getAll(); | ||
const readUsers = yield userMapperReturningID.select().returnAll(); | ||
expect(readUsers.length).toEqual(3); | ||
@@ -222,3 +228,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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -231,3 +237,3 @@ const updateCount = yield userMapperReturningAll | ||
.select('id', '>', insertReturns[0].id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -239,3 +245,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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
const updateValues = { email: 'new.email@xyz.pdq' }; | ||
@@ -248,3 +254,3 @@ const updateCount = yield userMapperReturningDefault | ||
.select('id', '>', insertReturns[0].id) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers.length).toEqual(2); | ||
@@ -256,3 +262,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().getAll(USERS); | ||
const insertReturns = yield userMapperReturningID.insert().returnAll(USERS); | ||
const updateValues1 = { email: 'foo@xyz.pdq' }; | ||
@@ -272,3 +278,3 @@ const updateCount = yield userMapperReturningAll | ||
])) | ||
.getAll(updateValues2); | ||
.returnAll(updateValues2); | ||
expect(updateReturns).toEqual([ | ||
@@ -289,9 +295,9 @@ { id: insertReturns[0].id }, | ||
{ notThere: 'xyz' }) | ||
.getAll({ email: 'abc@def.ghi' }); | ||
.returnAll({ email: 'abc@def.ghi' }); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update('notThere', '=', 'foo').getAll({ | ||
userMapperReturningID.update('notThere', '=', 'foo').returnAll({ | ||
email: 'abc@def.ghi', | ||
}); | ||
// @ts-expect-error - table must have all filter fields | ||
userMapperReturningID.update('notThere', '=', 'foo').getAll({ | ||
userMapperReturningID.update('notThere', '=', 'foo').returnAll({ | ||
email: 'abc@def.ghi', | ||
@@ -302,4 +308,4 @@ }); | ||
// @ts-expect-error - update must only have table columns | ||
.getAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).getAll( | ||
.returnAll({ notThere: 'xyz@pdq.xyz' }); | ||
userMapperReturningID.update({ id: 32 }).returnAll( | ||
// @ts-expect-error - update must only have table columns | ||
@@ -309,6 +315,6 @@ { notThere: 'xyz@pdq.xyz' }); | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).returnAll(USERS[0]))[0].name; | ||
// @ts-expect-error - only requested columns are accessible | ||
// prettier-ignore | ||
(yield userMapperReturningID.update({ id: 32 }).getAll(USERS[0]))[0].name; | ||
(yield userMapperReturningID.update({ id: 32 }).returnAll(USERS[0]))[0].name; | ||
yield userMapperReturningID | ||
@@ -323,3 +329,3 @@ .update(({ or, cmpr }) => | ||
or([cmpr('notThere', '=', 'xyz'), cmpr('alsoNotThere', '=', 'Sue')])) | ||
.getAll(USERS[0]); | ||
.returnAll(USERS[0]); | ||
// @ts-expect-error - ID filter must have correct type | ||
@@ -352,3 +358,3 @@ userMapperReturningID.update('str'); | ||
.insert() | ||
.getAll([userRow1, userRow2, userRow3]); | ||
.returnAll([userRow1, userRow2, userRow3]); | ||
const updatingUser1 = UpdatingUser.create(0, Object.assign({}, userObject1, { firstName: 'Suzanne' })); | ||
@@ -360,3 +366,3 @@ const updateReturns = yield mapper | ||
])) | ||
.getAll(updatingUser1); | ||
.returnAll(updatingUser1); | ||
expect(updateReturns).toEqual([ | ||
@@ -369,3 +375,3 @@ { id: insertReturns[0].id }, | ||
.modify((qb) => qb.orderBy('id')) | ||
.getAll(); | ||
.returnAll(); | ||
expect(readUsers).toEqual([ | ||
@@ -395,6 +401,6 @@ Object.assign({}, userRow1, { | ||
.insert() | ||
.getOne(userRow1); | ||
.returnOne(userRow1); | ||
const updateReturn = yield updateReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getAll({ name: 'Suzanne Smith' }); | ||
.returnAll({ name: 'Suzanne Smith' }); | ||
expect(updateReturn).toEqual([ | ||
@@ -421,6 +427,6 @@ new ReturnedUser(insertReturn.id, 'Suzanne', 'Smith', '(handle)', '(email)'), | ||
.insert() | ||
.getOne(userRow1); | ||
.returnOne(userRow1); | ||
const updateReturn = yield updateAndReturnTransformMapper | ||
.update({ id: insertReturn.id }) | ||
.getAll(UpdatingUser.create(0, userObject1)); | ||
.returnAll(UpdatingUser.create(0, userObject1)); | ||
expect(updateReturn).toEqual([ | ||
@@ -427,0 +433,0 @@ new ReturnedUser(insertReturn.id, userObject1.firstName, userObject1.lastName, userObject1.handle, userObject1.email), |
@@ -31,7 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const userWithID = new MappedUser(1, USERS[0].name, USERS[0].handle, USERS[0].email); | ||
const updateReturn1 = yield userMapper.update({ id: 1 }).getOne(userWithID); | ||
const updateReturn1 = yield userMapper | ||
.update({ id: 1 }) | ||
.returnOne(userWithID); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user with falsy id | ||
const insertedUser1 = new MappedUser(0, USERS[0].name, USERS[0].handle, USERS[0].email); | ||
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1)); | ||
const insertReturn1 = (yield userMapper.insert().returnOne(insertedUser1)); | ||
expect(insertReturn1).not.toBeNull(); | ||
@@ -43,3 +45,3 @@ expect(insertReturn1.id).toBeGreaterThan(0); | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser1).toEqual(Object.assign(Object.assign({}, insertedUser1), { id: insertReturn1.id })); | ||
@@ -51,3 +53,3 @@ // ensure 'id' is accessible | ||
const insertedUser2 = new MappedUser(10, USERS[1].name, USERS[1].handle, USERS[1].email); | ||
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2)); | ||
const insertReturn2 = (yield userMapper.insert().returnOne(insertedUser2)); | ||
expect(insertReturn2).toEqual(insertedUser2); | ||
@@ -57,3 +59,3 @@ insertReturn2 === null || insertReturn2 === void 0 ? void 0 : insertReturn2.name; // ensure 'name' is accessible | ||
.select({ id: insertReturn2.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser2).toEqual(insertedUser2); | ||
@@ -64,3 +66,3 @@ // test updating a user, with returned object | ||
.update({ id: updatingUser.id }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.name; // ensure 'name' is accessible | ||
@@ -70,3 +72,3 @@ expect(updateReturn).toEqual(updatingUser); | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toEqual(updatingUser); | ||
@@ -81,9 +83,13 @@ // test updating a user, without returned object | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4).toEqual(updatingUser2); | ||
// test updating multiple users returning select columns | ||
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' }); | ||
const updateReturn3 = yield userMapper | ||
.update() | ||
.returnAll({ name: 'Everyone' }); | ||
expect(updateReturn3).toEqual([{ id: 1 }, { id: 10 }]); | ||
updateReturn3[0].id; // ensure 'id' is accessible | ||
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' }); | ||
const updateReturn4 = yield userMapper | ||
.update() | ||
.returnOne({ name: 'Everyone' }); | ||
expect(updateReturn4).toEqual({ id: 1 }); | ||
@@ -96,3 +102,3 @@ updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible | ||
.select({ id: insertReturn1.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser5).toBeNull(); | ||
@@ -142,7 +148,7 @@ })); | ||
.update({ id: 1 }) | ||
.getOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email)); | ||
.returnOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email)); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user | ||
const insertedUser = new MappedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().returnOne(insertedUser)); | ||
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -154,3 +160,3 @@ expect(insertReturn).not.toBeNull(); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible | ||
@@ -163,3 +169,3 @@ expect(selectedUser1).toEqual(insertReturn); | ||
.update({ id: updatingUser.serialNo }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn2 === null || updateReturn2 === void 0 ? void 0 : updateReturn2.firstName; // ensure 'firstName' is accessible | ||
@@ -169,3 +175,3 @@ expect(updateReturn2).toEqual(updatingUser); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.firstName; // ensure 'firstName' is accessible | ||
@@ -177,3 +183,3 @@ expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.serialNo).toEqual(selectedUser1.serialNo); | ||
.update('id', '=', insertReturn.serialNo) | ||
.getAll({ | ||
.returnAll({ | ||
name: 'Foo Foo', | ||
@@ -185,9 +191,13 @@ }); | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4 === null || selectedUser4 === void 0 ? void 0 : selectedUser4.firstName).toEqual('Foo'); | ||
// test updating multiple users returning select columns | ||
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' }); | ||
const updateReturn3 = yield userMapper | ||
.update() | ||
.returnAll({ name: 'Everyone' }); | ||
expect(updateReturn3).toEqual([{ id: 1 }]); | ||
updateReturn3[0].id; // ensure 'id' is accessible | ||
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' }); | ||
const updateReturn4 = yield userMapper | ||
.update() | ||
.returnOne({ name: 'Everyone' }); | ||
expect(updateReturn4).toEqual({ id: 1 }); | ||
@@ -200,3 +210,3 @@ updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible | ||
.select({ id: insertReturn.serialNo }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toBeNull(); | ||
@@ -230,7 +240,7 @@ })); | ||
.update({ id: 1 }) | ||
.getOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email)); | ||
.returnOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email)); | ||
expect(updateReturn1).toEqual(null); | ||
// test inserting a user | ||
const insertedUser = new MappedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email); | ||
const insertReturn = (yield userMapper.insert().getOne(insertedUser)); | ||
const insertReturn = (yield userMapper.insert().returnOne(insertedUser)); | ||
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -242,3 +252,3 @@ expect(insertReturn).not.toBeNull(); | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible | ||
@@ -251,3 +261,3 @@ expect(selectedUser1).toEqual(insertReturn); | ||
.update({ id: updatingUser.id }) | ||
.getOne(updatingUser); | ||
.returnOne(updatingUser); | ||
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.firstName; // ensure 'firstName' is accessible | ||
@@ -257,3 +267,3 @@ expect(updateReturn).toEqual(updatingUser); | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser2).toEqual(updatingUser); | ||
@@ -268,3 +278,3 @@ // test updating a user, without returned object | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser3).toEqual(updatingUser2); | ||
@@ -276,3 +286,3 @@ // test deleting a user | ||
.select({ id: insertReturn.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser4).toBeNull(); | ||
@@ -296,3 +306,3 @@ })); | ||
insertedUser1.firstName, insertedUser1.handle, insertedUser1.email); | ||
const insertReturn = yield userMapper.insert().getOne(insertedUser); | ||
const insertReturn = yield userMapper.insert().returnOne(insertedUser); | ||
expect(insertReturn).toBeUndefined(); | ||
@@ -302,5 +312,5 @@ // test getting a user by ID | ||
.select({ id: insertedUser.id }) | ||
.getOne(); | ||
.returnOne(); | ||
expect(selectedUser1).toEqual(insertedUser); | ||
})); | ||
//# sourceMappingURL=UniformTableMapper.test.js.map |
{ | ||
"name": "kysely-mapper", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"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
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
643514
7481