MCPcopy Index your code
hub / github.com/reactjs/server-components-demo / seed

Function seed

scripts/seed.js:64–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62];
63
64async function seed() {
65 await pool.query(dropTableStatement);
66 await pool.query(createTableStatement);
67 const res = await Promise.all(
68 seedData.map((row) => pool.query(insertNoteStatement, row))
69 );
70
71 const oldNotes = await readdir(path.resolve(NOTES_PATH));
72 await Promise.all(
73 oldNotes
74 .filter((filename) => filename.endsWith('.md'))
75 .map((filename) => unlink(path.resolve(NOTES_PATH, filename)))
76 );
77
78 await Promise.all(
79 res.map(({rows}) => {
80 const id = rows[0].id;
81 const content = rows[0].body;
82 const data = new Uint8Array(Buffer.from(content));
83 return writeFile(path.resolve(NOTES_PATH, `${id}.md`), data, (err) => {
84 if (err) {
85 throw err;
86 }
87 });
88 })
89 );
90}
91
92seed();

Callers 1

seed.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected