24 lines
551 B
JavaScript
24 lines
551 B
JavaScript
const Category = require("../models/Category");
|
|
|
|
module.exports.getAll = [
|
|
async (req, res) => {
|
|
try {
|
|
const shafafCategory = await Category.findOne({ title: "شفافیت" });
|
|
if (!shafafCategory)
|
|
return res.status(404).json({
|
|
message: "شفافیت یافت نشد",
|
|
});
|
|
|
|
const shafafItems = await Category.find({
|
|
parent: shafafCategory._id,
|
|
});
|
|
|
|
return res.json({
|
|
data: shafafItems,
|
|
});
|
|
} catch (error) {
|
|
return res500(res, error.message);
|
|
}
|
|
},
|
|
];
|