From 9f069f6ea19aea1f2644f400b6b466360a0a88ec Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 26 Jun 2022 17:06:34 +0200 Subject: [PATCH] Created the "bought item" controller --- controller/boughtItem.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 controller/boughtItem.js diff --git a/controller/boughtItem.js b/controller/boughtItem.js new file mode 100644 index 0000000..8456677 --- /dev/null +++ b/controller/boughtItem.js @@ -0,0 +1,9 @@ +const {mongo} = require('mongoose'); +const BoughtItem = require('../models/BoughtItem'); + +// Checks if the user owns a specific addon +module.exports.ownsItem = async (user_id, addon_id) => { + if (!mongo.ObjectId.isValid(user_id)) return; + if (!mongo.ObjectId.isValid(addon_id)) return; + return await BoughtItem.findOne({user_id, addon_id}).exec() !== null; +} \ No newline at end of file