Replace custom ShopConfig pages/models with registerConfigBlocks, load config from Config store, and enforce RBAC on methods. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
835 B
JavaScript
21 lines
835 B
JavaScript
const { DB } = require('@orbito/api-lib');
|
|
|
|
const schema = new DB.Schema('ps_orders', {
|
|
// Identyfikator sklepu z Config (SHOP_ID = 'default'); wcześniej ObjectId z ShopConfig.
|
|
shopConfigId: { type: 'string' },
|
|
psOrderId: { type: 'number' },
|
|
orbitoOrderId: { type: 'ObjectId', optional: true },
|
|
reference: { type: 'string', optional: true, default: '' },
|
|
syncedAt: { type: 'date', optional: true, default: () => new Date() },
|
|
paymentSyncedAt: { type: 'date', optional: true },
|
|
});
|
|
|
|
schema.pre('validate', function (data) {});
|
|
schema.post('create', function (data) {});
|
|
|
|
DB.createIndex('ps_orders', { psOrderId: 1, shopConfigId: 1 }, { unique: true });
|
|
DB.createIndex('ps_orders', { orbitoOrderId: 1 });
|
|
DB.createIndex('ps_orders', { syncedAt: -1 });
|
|
|
|
module.exports = schema;
|