'How to use two schemas to create two collections in mongoose
I'm storing some data I'm getting from API calls in a collection ('Asin'). - work just fine.
I build two pages -register & log in, installed all relevant bcrypt and saltRound modules.
But it seems that when I'm registering as a user, I'm not rendering to a "secret page" (in my case the homepage) and mongoose is not creating a new collection ('Users') in the mongo shell at all.
const mongoose = require('mongoose');
const bcrypt = require("bcrypt");
const saltRounds = 10;
const app = express();
app.set('view engine', 'ejs');
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended: true}));
mongoose.connect("mongodb://localhost:27017/asinDB", {useNewUrlParser: true,
useUnifiedTopology: true});
const asinSchema = new mongoose.Schema ({
asinId:String,
parentAsinId:String,
categoryId:String,
feesId:Number,
buyBoxpriceId:Number
});
const userSchema = new mongoose.Schema({
email:String,
password:String
});
const Asin = mongoose.model("Asin", asinSchema);
const User = new mongoose.model("User",userSchema);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|