mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
added and fix some of things
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ const { Op } = require("sequelize");
|
||||
const sequelize = require("../config/db.config");
|
||||
const Sequelize = require("sequelize");
|
||||
const R = require("../utils/response.util"); // adjust path as needed
|
||||
const mdl_TierCategories = require("../models/tiers/tier_categories.mdl");
|
||||
|
||||
const auditByFields = ["createdBy", "updatedBy", "deletedBy"];
|
||||
|
||||
@@ -42,6 +43,18 @@ const getFieldValues = (Model, logTag, options = {}) => async (req, res) => {
|
||||
return R.success(res, "Field values retrieved.", ["true", "false"]);
|
||||
}
|
||||
|
||||
// ─── Tier gate fields — same reasoning as ENUM above: the picklist should
|
||||
// reflect every tier category that exists, not just whichever ones a
|
||||
// DISTINCT scan happens to find already assigned to a row.
|
||||
if (field === "subscription") {
|
||||
const categories = await mdl_TierCategories.findAll({
|
||||
where: { is_active: true },
|
||||
order: [["rank", "ASC"]],
|
||||
raw: true,
|
||||
});
|
||||
return R.success(res, "Field values retrieved.", categories.map((c) => ({ value: c.slug, label: c.name })));
|
||||
}
|
||||
|
||||
if (auditByFields.includes(field)) {
|
||||
// Filtering must match the audit column's real (bigint) id — returning
|
||||
// just the display name here previously made buildWhere() compare a
|
||||
|
||||
Reference in New Issue
Block a user