Skip to content

Commit

Permalink
feat(mongodb): add mongodb
Browse files Browse the repository at this point in the history
- add separate files for mongodb setup
- closes [momi-foundation-coding#2](momi-foundation-coding#2 (comment))
  • Loading branch information
Nicanor008 committed Aug 19, 2019
1 parent df2456a commit 6c99874
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/createapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const installingDependancies = (name) => {
npm install bcrypt
npm install pg-hstore
npm install dotenv
npm install mongoose
echo Install dev dependancies, please wait...
npm install -D @babel/cli
npm install -D @babel/core
Expand Down
27 changes: 27 additions & 0 deletions tasks/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,33 @@ sequelize
export default sequelize;
`;

const mongooseSetupData = `
import mongoose from 'mongoose';
const sequelize = mongoose.connect('mongodb://localhost:27017/test',

This comment has been minimized.

Copy link
@ezkemboi

ezkemboi Nov 23, 2019

We can make use of mongoose instead of sequelize.

{useNewUrlParser: true});
sequelize.then(() =>{
console.log('MongoDB Connection has been established successfully.')
})
.catch( err => {
console.error('Unable to connect to the database:', err);
});
export default sequelize;
`;

const MongooseUserModelData = `
import mongoose from 'mongoose';
const userSchema = new mongoose.Schema({
firstName: { type: String },
lastName: { type: String },
email: { type: String },
password: { type: String }
});
export default mongoose.model("User", userSchema);
`;

const userModelData =
`import Sequelize, { Model } from 'sequelize';
import bcrypt from 'bcrypt';
Expand Down

1 comment on commit 6c99874

@ezkemboi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please share a PR on this one @Nicanor008.

Thanks.

Please sign in to comment.