@platformatic/sql-mapper
Advanced tools
Comparing version
@@ -245,9 +245,10 @@ import { FastifyPluginAsync, FastifyInstance, FastifyReply, FastifyRequest } from 'fastify' | ||
type EntityHook<T extends (...args: any) => any> = (original: T, ...options: Parameters<T>) => ReturnType<T>; | ||
export interface EntityHooks<EntityFields = any> { | ||
find?: Find<EntityFields>, | ||
insert?: Insert<EntityFields>, | ||
save?: Save<EntityFields>, | ||
delete?: Delete<EntityFields>, | ||
count?: Count, | ||
find?: EntityHook<Find<EntityFields>>, | ||
insert?: EntityHook<Insert<EntityFields>>, | ||
save?: EntityHook<Save<EntityFields>>, | ||
delete?: EntityHook<Delete<EntityFields>>, | ||
count?: EntityHook<Count>, | ||
} | ||
@@ -254,0 +255,0 @@ |
{ | ||
"name": "@platformatic/sql-mapper", | ||
"version": "0.31.0", | ||
"version": "0.31.1", | ||
"description": "A data mapper utility for SQL databases", | ||
@@ -32,3 +32,3 @@ "main": "mapper.js", | ||
"inflected": "^2.1.0", | ||
"@platformatic/types": "0.31.0" | ||
"@platformatic/types": "0.31.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "tsd": { |
@@ -45,7 +45,7 @@ import { expectType } from 'tsd' | ||
const entityHooks: EntityHooks = { | ||
async find(options: any): Promise<any[]> { return [] }, | ||
async insert(options: { inputs: any[], fields?: string[] }): Promise<any[]> { return [] }, | ||
async save(options: { input: any, fields?: string[] }): Promise<any> { return {} }, | ||
async delete(options?: { where: WhereCondition, fields: string[] }): Promise<any[]> { return [] }, | ||
async count(options?: { where?: WhereCondition }): Promise<number> { return 0 }, | ||
async find(originalFind: typeof entity.find, ...options: Parameters<typeof entity.find>): ReturnType<typeof entity.find> { return [] }, | ||
async insert(originalInsert: typeof entity.insert, ...options: Parameters<typeof entity.insert>): ReturnType<typeof entity.insert> { return [] }, | ||
async save(originalSave: typeof entity.save, ...options: Parameters<typeof entity.save>): ReturnType<typeof entity.save> { return {} }, | ||
async delete(originalDelete: typeof entity.delete, ...options: Parameters<typeof entity.delete>): ReturnType<typeof entity.delete> { return [] }, | ||
async count(originalCount: typeof entity.count, ...options: Parameters<typeof entity.count>): ReturnType<typeof entity.count> { return 0 }, | ||
} | ||
@@ -52,0 +52,0 @@ expectType<EntityHooks>(entityHooks) |
165760
0.28%5231
0.02%+ Added
- Removed
Updated