ehmpathy / sql-dao-generator

Generate data-access-objects from your domain-objects
MIT License
0 stars 0 forks source link

support alternate unique keys #10

Open uladkasach opened 2 years ago

uladkasach commented 2 years ago

for example:

uladkasach commented 2 years ago

may want to make the exposed dao method:

findByUnique(args: { slug: string } | { forUrl: string }) => { ... }

so that its clear its unique on both - and to continue the expectation that each domain object can be "foundByUnique"

uladkasach commented 2 years ago

another example:

export class Lot extends DomainEntity<Lot> implements Lot {
  public static unique = [
    ['requestUuid'], // ensures retried client requests do not result in more than one lot (since lotNumber is generated inside of the service)
    ['auctionUuid', 'lotNumber'] // ensures a lot number is used max once per auction
  ];
}