back to Mongo Atlas | price -> prices
This commit is contained in:
@@ -64,7 +64,9 @@
|
||||
- ##### **restaurantId**: _mongoose.Types.ObjectId_
|
||||
- ##### **name**: _String_ (max: 128, required)
|
||||
- ##### **category**: _String_ (max: 64, required)
|
||||
- ##### **price**: String (required)
|
||||
- ##### **prices**: (max elements 3)
|
||||
- ##### **priceName**: _String_ (required)
|
||||
- ##### **price**: _String_ (required)
|
||||
- ##### **notes**: _String_ (max: 128)
|
||||
- ##### **imgUrl**: _String_ (required)
|
||||
- ##### **hidden**: _Boolean_
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
const mongoose = require("mongoose");
|
||||
const {
|
||||
dbPass,
|
||||
dbUser,
|
||||
/* dbUser,
|
||||
dbHost,
|
||||
dbPort,
|
||||
dbPort, */
|
||||
dbName,
|
||||
} = require("../config/index.js");
|
||||
|
||||
const loadMongoose = async () => {
|
||||
const connection = await mongoose.connect(
|
||||
"mongodb://" +
|
||||
dbHost +
|
||||
":" +
|
||||
dbPort +
|
||||
"/" +
|
||||
dbName +
|
||||
"?ssl=true&replicaSet=globaldb",
|
||||
`mongodb+srv://menui_db_user:${dbPass}@menui-database.9quwf.mongodb.net/${dbName}?retryWrites=true&w=majority`,
|
||||
{
|
||||
auth: {
|
||||
user: dbUser,
|
||||
password: dbPass,
|
||||
},
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
retryWrites: false,
|
||||
},
|
||||
(err) => {
|
||||
if (err) console.log("Unable to connect :(");
|
||||
@@ -33,3 +22,13 @@ const loadMongoose = async () => {
|
||||
};
|
||||
|
||||
module.exports = loadMongoose;
|
||||
|
||||
|
||||
// AZURE
|
||||
/* "mongodb://" +
|
||||
dbHost +
|
||||
":" +
|
||||
dbPort +
|
||||
"/" +
|
||||
dbName +
|
||||
"?ssl=true&replicaSet=globaldb", */
|
||||
@@ -13,10 +13,20 @@ const dishSchema = mongoose.Schema({
|
||||
maxlength: 64,
|
||||
required: true,
|
||||
},
|
||||
price: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
prices: [
|
||||
{
|
||||
priceName: {
|
||||
type: String,
|
||||
maxlength: 60,
|
||||
required: true
|
||||
},
|
||||
price: {
|
||||
type: String,
|
||||
maxlength: 20,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
],
|
||||
notes: {
|
||||
type: String,
|
||||
maxlength: 200,
|
||||
|
||||
@@ -131,7 +131,7 @@ async function createDish(dish, restaurantId, oldDish) {
|
||||
restaurantId: restaurantId,
|
||||
name: sanitizer.sanitize.keepUnicode(dish.name),
|
||||
category: dish.category,
|
||||
price: dish.price,
|
||||
prices: dish.prices,
|
||||
notes: sanitizer.sanitize.keepUnicode(dish.notes),
|
||||
imgUrl: img,
|
||||
weight: dish.weight,
|
||||
@@ -149,7 +149,7 @@ async function createDish(dish, restaurantId, oldDish) {
|
||||
restaurantId: oldDish.restaurantId,
|
||||
name: sanitizer.sanitize.keepUnicode(dish.name),
|
||||
category: dish.category,
|
||||
price: dish.price,
|
||||
prices: dish.prices,
|
||||
notes: sanitizer.sanitize.keepUnicode(dish.notes),
|
||||
imgUrl: img,
|
||||
weight: dish.weight,
|
||||
@@ -164,7 +164,7 @@ async function createDish(dish, restaurantId, oldDish) {
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw newError("Cannot create dish", 500);
|
||||
throw newError("Cannot create dish because: " + e, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user