import { getMetadataFromDecorator } from '../utils.js';
function createDecorator(options, unique) {
  return function (target, propertyName) {
    const meta = getMetadataFromDecorator(propertyName ? target.constructor : target);
    options.properties ??= propertyName;
    const key = unique ? 'uniques' : 'indexes';
    meta[key].push(options);
    if (!propertyName) {
      return target;
    }
    return undefined;
  };
}
/** Defines a database index on a property or entity class (legacy TypeScript decorator). */
export function Index(options = {}) {
  return createDecorator(options, false);
}
/** Defines a unique constraint on a property or entity class (legacy TypeScript decorator). */
export function Unique(options = {}) {
  return createDecorator(options, true);
}
