-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseed.js
42 lines (38 loc) · 883 Bytes
/
seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const db = require("./src/db");
const fs = require("fs/promises");
const path = require("path");
async function seedDb() {
const file = await fs.readFile(path.join(__dirname, "./data/pokedex.json"));
const pokedex = JSON.parse(file.toString());
for (let pokemon of pokedex) {
console.log({
...pokemon,
en: pokemon.name.english,
jp: pokemon.name.japanese,
ch: pokemon.name.chinese,
fr: pokemon.name.french,
});
await db
.put({
TableName: "baselime-pokedex-prod",
Item: {
...pokemon,
game: 'pokemon',
en: pokemon.name.english,
jp: pokemon.name.japanese,
ch: pokemon.name.chinese,
fr: pokemon.name.french,
},
})
.promise();
await db.put({
TableName: "baselime-pokedex-prod-counter",
Item: {
id: "pokedex",
count: 1
}
}).promise()
}
}
seedDb();
exports.handler = seedDb;