aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-11 19:44:52 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-11 19:44:52 +0300
commit1cecd0202f6f891d5f76132ee17353c6e35d91a8 (patch)
tree2883fcce39ce28524e3883f509253fc8d83fc2a9
parent40b804ffdd26a0c9bab95b4ec6a539d9fe429ed3 (diff)
downloadwhich-api-1cecd0202f6f891d5f76132ee17353c6e35d91a8.tar.gz
feat: add populateDb script
-rw-r--r--populateDb.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/populateDb.ts b/populateDb.ts
new file mode 100644
index 0000000..1442350
--- /dev/null
+++ b/populateDb.ts
@@ -0,0 +1,28 @@
+import mongoose from 'mongoose';
+import app from './app';
+
+mongoose.connect('mongodb://localhost:27017/which', { useNewUrlParser: true });
+
+import UserModel from './models/users/user.model';
+(async () => {
+ const users = [
+ { name: "Emma" },
+ { name: "Elise" },
+ { name: "Jack" },
+ { name: "Oliver" },
+ { name: "Jamie" },
+ { name: "Aidan" },
+ { name: "Jordan" },
+ { name: "Erin" },
+ { name: "William" },
+ { name: "Ethan" },
+ ];
+ try {
+ for (const user of users) {
+ await UserModel.create(user);
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ mongoose.disconnect();
+})(); \ No newline at end of file