-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
db
] Replace faker
with @faker-js/faker
- Loading branch information
Showing
7 changed files
with
23 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint | ||
yarn prettier --check . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* SPDX-FileCopyrightText: 2016-present Kriasoft <[email protected]> */ | ||
/* SPDX-License-Identifier: MIT */ | ||
|
||
import { date, image, internet, name, random } from "faker"; | ||
import faker from "@faker-js/faker"; | ||
import { type Knex } from "knex"; | ||
import nanoid from "nanoid"; | ||
import fs from "node:fs/promises"; | ||
|
@@ -11,6 +11,7 @@ import prettier from "prettier"; | |
// https://zelark.github.io/nano-id-cc/ | ||
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; | ||
const newUserId = nanoid.customAlphabet(alphabet, 6); | ||
const { date, image, internet, name, random } = faker; | ||
|
||
function stringify(obj: Record<string, unknown>) { | ||
return prettier.format(JSON.stringify(obj), { parser: "json" }); | ||
|
@@ -62,5 +63,5 @@ export async function seed(db: Knex) { | |
await fs.writeFile(jsonFile, stringify(users)); | ||
} | ||
|
||
await db.table("user").insert(users); | ||
await db.table("user").insert(users).onConflict(["id"]).ignore(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters