|
|
@@ -17,7 +17,7 @@ const addMenu = async (userID: string, menuLimit: number, input: AddMenuInput):
|
|
|
} = input;
|
|
|
|
|
|
const menuCount = await Menu.countDocuments({
|
|
|
- userID
|
|
|
+ userID: new mongoose.Types.ObjectId(userID)
|
|
|
});
|
|
|
|
|
|
if (menuCount >= menuLimit) {
|
|
|
@@ -27,6 +27,20 @@ const addMenu = async (userID: string, menuLimit: number, input: AddMenuInput):
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ if (isActive) {
|
|
|
+ await Menu.updateMany(
|
|
|
+ {
|
|
|
+ userID: new mongoose.Types.ObjectId(userID),
|
|
|
+ isActive: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $set: {
|
|
|
+ isActive: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
const newMenu = await Menu.create({
|
|
|
userID: new mongoose.Types.ObjectId(userID),
|
|
|
isViewPrice,
|