artmapper
Version:
A simple and intuitive ORM for Node.js with TypeScript and JavaScript support
66 lines • 1.69 kB
TypeScript
export type DatabaseType = 'mysql' | 'postgresql' | 'sqlite' | 'mongodb';
export interface DatabaseConfig {
type: DatabaseType;
host?: string;
port?: number;
username?: string;
password?: string;
database: string;
options?: Record<string, any>;
}
export interface QueryOptions {
where?: Record<string, any>;
orderBy?: Record<string, 'ASC' | 'DESC'>;
limit?: number;
offset?: number;
select?: string[];
include?: string[];
}
export interface QueryResult<T = any> {
data: T[];
count: number;
}
export interface Entity {
id?: any;
[key: string]: any;
}
export declare class ArtMapperError extends Error {
constructor(message: string);
}
export interface ModelDefinition {
table: string;
fields: Record<string, FieldDefinition>;
relations?: RelationDefinition[];
mappings?: TableMapping[];
}
export interface FieldDefinition {
type: string;
primary?: boolean;
primaryKey?: boolean;
autoIncrement?: boolean;
nullable?: boolean;
notNull?: boolean;
unique?: boolean;
default?: any;
length?: number;
}
export interface RelationDefinition {
type: 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany';
model: string;
foreignKey?: string;
localKey?: string;
through?: string;
}
export interface TableMapping {
name: string;
targetTable: string;
type: 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
foreignKey: string;
localKey?: string;
through?: string;
fields?: string[];
}
export interface MappedQueryResult<T = any> extends QueryResult<T> {
mapped?: Record<string, any[]>;
}
//# sourceMappingURL=types.d.ts.map