Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add types for realm #278

Merged
merged 5 commits into from
Feb 22, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ export class Bone {
toObject(): InstanceValues<this>;
}

interface ConnectOptions {
export interface ConnectOptions {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to port it to egg-orm

client?: 'mysql' | 'mysql2' | 'pg' | 'sqlite3' | '@journeyapps/sqlcipher';
dialect?: 'mysql' | 'postgres' | 'sqlite';
host?: string;
Expand All @@ -612,6 +612,11 @@ interface InitOptions {
};
}

interface SyncOptions {
force?: boolean;
alter?: boolean;
}

type RawSql = {
__raw: true,
value: string,
Expand All @@ -634,8 +639,8 @@ export default class Realm {
define(
name: string,
attributes: Record<string, AttributeMeta>,
options: InitOptions,
descriptors: Record<string, Function>,
options?: InitOptions,
descriptors?: Record<string, Function>,
cyjake marked this conversation as resolved.
Show resolved Hide resolved
): Bone;

raw(sql: string): RawSql;
Expand All @@ -646,6 +651,8 @@ export default class Realm {

transaction(callback: GeneratorFunction): Promise<void>;
transaction(callback: (connection: Connection) => Promise<void>): Promise<void>;

sync(options?: SyncOptions): Promise<void>;
}

/**
Expand Down