/**
 * Options for when constructing a Collection.
 * @author Benedikt Arnarsson
 */
type CollectionOpts = (
  // Opts that are independent of concurrency
  {
    // If provided, will delete documents after the set number of seconds
    expireAfterSeconds?: number,
    // Extra secondary index keys, for querying
    indexKeys?: string[],
  } & (
    // Supports concurrency
    | {
      supportConcurrency: true,
      // The max time that a collection will wait for a lock
      atomicUpdateTimeoutMs?: number,
      // Primary index key, must be 'id' for concurrent collections
      uniqueIndexKey: 'id',
    }
    // Doesn't support concurrency
    | {
      supportConcurrency?: false,
      // see above, undefined for non-concurrent collections
      atomicUpdateTimeoutMs?: undefined,
      // Optional primary index key
      uniqueIndexKey?: string,
    }
  )
);

export default CollectionOpts;
