mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Adjusted
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// models/assets/assets.attributes.js
|
||||
|
||||
// ─── Exclude sets ─────────────────────────────────────────────────────────────
|
||||
|
||||
// Fields hidden from all roles (sensitive / internal storage details)
|
||||
const excludeAttributes = [
|
||||
"checksum", // internal integrity hash, not useful to clients
|
||||
"storage_bucket", // internal storage config
|
||||
"storage_key", // internal Chibisafe / S3 key
|
||||
"deletedBy", // exposed via audit subquery as a name instead
|
||||
];
|
||||
|
||||
// Admins see everything except the base excludes
|
||||
const adminExclude = [
|
||||
...excludeAttributes,
|
||||
];
|
||||
|
||||
// Regular users also cannot see audit trails or soft-delete info
|
||||
const userExclude = [
|
||||
...excludeAttributes,
|
||||
"uploadedBy",
|
||||
"deletedAt",
|
||||
];
|
||||
|
||||
// ─── No JSONB columns on assets ───────────────────────────────────────────────
|
||||
// Assets has no JSONB columns so jsonbSchemas stays empty.
|
||||
const jsonbSchemas = {};
|
||||
|
||||
// ─── Computed attributes ──────────────────────────────────────────────────────
|
||||
// Add any SQL-computed fields here (e.g. a view count join).
|
||||
// Format: { key, label, type, order, literal }
|
||||
const computedAttributes = [
|
||||
// Example:
|
||||
// {
|
||||
// key: "viewCount",
|
||||
// label: "Views",
|
||||
// type: "number",
|
||||
// order: 99,
|
||||
// literal: `(SELECT COUNT(*) FROM "asset_views" WHERE "asset_views"."asset_id" = "Asset"."asset_id")`,
|
||||
// },
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
excludeAttributes,
|
||||
adminExclude,
|
||||
userExclude,
|
||||
jsonbSchemas,
|
||||
computedAttributes,
|
||||
};
|
||||
@@ -59,7 +59,7 @@ const Asset = sequelize.define("Asset", {
|
||||
},
|
||||
|
||||
// ─── Polymorphic ownership ────────────────────────────────────────────────
|
||||
owner_type: { type: DataTypes.STRING(100) }, // e.g. "Course", "Channel", "Post", "User"
|
||||
owner_type: { type: DataTypes.STRING(100) }, // avatar, document, video, image
|
||||
owner_id: { type: DataTypes.BIGINT },
|
||||
|
||||
// ─── Who did what ─────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user