Skip to content

Commit

Permalink
orchid tests: primaryKey/foreignKey -> columns/references
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSemenov committed Jun 24, 2024
1 parent 5d33b01 commit 9de87aa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
8 changes: 4 additions & 4 deletions packages/orchid/docs/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class UserTable extends BaseTable {

relations = {
posts: this.hasMany(() => PostTable, {
primaryKey: "id",
foreignKey: "author_id",
columns: ["id"],
references: ["author_id"],
}),
}
}
Expand All @@ -78,8 +78,8 @@ class PostTable extends BaseTable {
relations = {
author: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "author_id",
columns: ["author_id"],
references: ["id"],
}),
}
}
Expand Down
13 changes: 2 additions & 11 deletions packages/orchid/tests/main/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class UserTable extends BaseTable {

relations = {
posts: this.hasMany(() => PostTable, {
primaryKey: "id",
foreignKey: "author_id",
columns: ["id"],
references: ["author_id"],
}),
}
}
Expand All @@ -29,14 +29,6 @@ class PostTable extends BaseTable {
author_id: t.integer(),
is_draft: t.boolean().default(false),
}))

relations = {
author: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "author_id",
}),
}
}

const db = await create_db({
Expand Down Expand Up @@ -70,7 +62,6 @@ const schema = gql`
type Post {
id: Int!
text: String!
author: User!
}
type Query {
Expand Down
40 changes: 20 additions & 20 deletions packages/orchid/tests/main/relation-pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class UserTable extends BaseTable {

relations = {
posts: this.hasMany(() => PostTable, {
primaryKey: "id",
foreignKey: "author_id",
columns: ["id"],
references: ["author_id"],
}),
comments: this.hasMany(() => CommentTable, {
primaryKey: "id",
foreignKey: "user_id",
columns: ["id"],
references: ["user_id"],
}),
likes: this.hasMany(() => LikeTable, {
primaryKey: "id",
foreignKey: "user_id",
columns: ["id"],
references: ["user_id"],
}),
}
}
Expand All @@ -40,12 +40,12 @@ class PostTable extends BaseTable {
relations = {
author: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "author_id",
columns: ["author_id"],
references: ["id"],
}),
comments: this.hasMany(() => CommentTable, {
primaryKey: "id",
foreignKey: "post_id",
columns: ["id"],
references: ["post_id"],
}),
}
}
Expand All @@ -63,16 +63,16 @@ class CommentTable extends BaseTable {
relations = {
user: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "user_id",
columns: ["user_id"],
references: ["id"],
}),
post: this.belongsTo(() => PostTable, {
primaryKey: "id",
foreignKey: "post_id",
columns: ["post_id"],
references: ["id"],
}),
likes: this.hasMany(() => LikeTable, {
primaryKey: "id",
foreignKey: "comment_id",
columns: ["id"],
references: ["comment_id"],
}),
}
}
Expand All @@ -89,12 +89,12 @@ class LikeTable extends BaseTable {
relations = {
user: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "user_id",
columns: ["user_id"],
references: ["id"],
}),
comment: this.belongsTo(() => CommentTable, {
primaryKey: "id",
foreignKey: "comment_id",
columns: ["comment_id"],
references: ["id"],
}),
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/orchid/tests/main/relations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class UserTable extends BaseTable {

relations = {
posts: this.hasMany(() => PostTable, {
primaryKey: "id",
foreignKey: "author_id",
columns: ["id"],
references: ["author_id"],
}),
}
}
Expand All @@ -32,8 +32,8 @@ class PostTable extends BaseTable {
relations = {
author: this.belongsTo(() => UserTable, {
required: true,
primaryKey: "id",
foreignKey: "author_id",
columns: ["author_id"],
references: ["id"],
}),
}
}
Expand Down

0 comments on commit 9de87aa

Please sign in to comment.