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