Skip to content

Commit

Permalink
chore: ts type definition correct, doc
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyDaddy committed Apr 26, 2022
1 parent 854863d commit f2ca523
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const { BIGINT, STRING } = Bone.DataTypes;
class Shop extends Bone {
static attributes = {
id: { type: BIGINT, primaryKey: true },
name: { type: STRING },
name: STRING,
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/querying.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ We can reference these table aliases futher after the join, such as `.where()` o

```js
Post.join(Comment, 'posts.id = comments.postId').where('comments.id = 1')
Post.join(Comment, 'posts.id = comments.postId').where({ 'comments.id': 1 })
```

## Scopes
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const { BIGINT, STRING } = Bone.DataTypes;
class Shop extends Bone {
static attributes = {
id: { type: BIGINT, primaryKey: true },
name: { type: STRING },
name: STRING,
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/zh/querying.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ SELECT * FROM posts LEFT JOIN comments ON posts.id = comments.post_id LEFT JOIN

```js
Post.join(Comment, 'posts.id = comments.postId').where('comments.id = 1')
Post.join(Comment, 'posts.id = comments.postId').where({ 'comments.id': 1 })
```

## 查询限定
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/types/data_types.ts → test/types/data_types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import Realm, { Bone, DataTypes } from '../..';
import Realm, { Bone, DataTypes } from '../../types';

describe('=> Data types (TypeScript)', function() {
const { STRING, TEXT, BLOB } = DataTypes;
Expand Down
8 changes: 7 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,17 @@ export interface ColumnMeta {
comment?: string;
datetimePrecision?: string;
}

declare type validator = Literal | Function | Array<Literal | Literal[]>;

export interface AttributeMeta extends ColumnMeta {
jsType?: Literal;
type: DataType;
virtual?: boolean,
toSqlString: () => string;
validate: {
[key: string]: validator;
}
}

interface RelateOptions {
Expand Down Expand Up @@ -442,7 +448,7 @@ export class Collection<T extends Bone> extends Array<T> {
}

export class Bone {
static DataTypes: DataType;
static DataTypes: typeof DataType;

/**
* get the connection pool of the driver
Expand Down

0 comments on commit f2ca523

Please sign in to comment.