aggiornamento visualizzazione Ordini e Carrello
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const Order = require('../models/order');
|
||||
|
||||
const CartSchema = new Schema({
|
||||
idapp: {
|
||||
@@ -31,10 +36,6 @@ const CartSchema = new Schema({
|
||||
|
||||
var Cart = module.exports = mongoose.model('Cart', CartSchema);
|
||||
|
||||
Cart.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp, userId) {
|
||||
const myfind = { idapp, userId };
|
||||
|
||||
@@ -43,6 +44,8 @@ module.exports.findAllIdApp = async function (idapp, userId) {
|
||||
|
||||
module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
try {
|
||||
const Order = require('../models/order');
|
||||
|
||||
let query = { userId: uid, idapp };
|
||||
const mycart = await Cart.findOne(query).lean();
|
||||
|
||||
@@ -130,3 +133,7 @@ module.exports.createCart = async function (newCart) {
|
||||
return await newCart.save();
|
||||
};
|
||||
|
||||
|
||||
Cart.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user