Skip to content

Instantly share code, notes, and snippets.

@rainrisa
Created August 1, 2023 08:45
Show Gist options
  • Save rainrisa/1111e46fd673e57def0d1c6c80b8a6aa to your computer and use it in GitHub Desktop.
Save rainrisa/1111e46fd673e57def0d1c6c80b8a6aa to your computer and use it in GitHub Desktop.
declare module "jdatas" {
function ID(cod: number): Promise<string>;
class File {
direct: string;
constructor(path: string, name: string);
create<T extends object>(data: T, encoding: string): Promise<T>;
read(encoding: string): Promise<object>;
update<T extends object>(newData: T): Promise<T>;
check(): Promise<boolean>;
}
class JSchema<T extends object> {
objSchema: T;
}
class JModel<UserSchema extends object> {
name: string;
file: File;
jschema: JSchema<UserSchema>;
id: typeof ID;
cod: number;
objSchema: UserSchema;
constructor(
name: string,
directory: string,
objSchema: UserSchema,
cod: number
);
save<T extends UserSchema>(data: T, id?: number): Promise<void>;
getAll(): Promise<UserSchema[]>;
findAll(obj: UserSchema): Promise<UserSchema>;
findExactly<T extends object>(obj: T): Promise<T>;
getId(search: string): Promise<string | string[]>;
findById(id: string, result: string): Promise<object>;
findById(id: string): Promise<object>;
}
function JDB(directory: string): {
model: <T extends object>(
name: string,
object: T,
cod: number
) => JModel<T>;
schema: <T>(obj: T) => T;
};
export = JDB;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment