diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-11 19:44:52 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-11 19:44:52 +0300 |
commit | 1cecd0202f6f891d5f76132ee17353c6e35d91a8 (patch) | |
tree | 2883fcce39ce28524e3883f509253fc8d83fc2a9 | |
parent | 40b804ffdd26a0c9bab95b4ec6a539d9fe429ed3 (diff) | |
download | which-api-1cecd0202f6f891d5f76132ee17353c6e35d91a8.tar.gz |
feat: add populateDb script
-rw-r--r-- | populateDb.ts | 28 |
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 |