import { FSDB_COLLECTION } from '@andyburke/fsdb';
import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers';
import { by_lurid } from '@andyburke/fsdb/organizers';

export type SESSION = {
	id: string;
	user_id: string;
	secret: string;
	timestamps: {
		created: string;
		expires: string;
		ended: string;
	};
};

export const SESSIONS = new FSDB_COLLECTION<SESSION>({
	name: 'sessions',
	indexers: {
		user_id: new FSDB_INDEXER_SYMLINKS<SESSION>({
			name: 'user_id',
			field: 'user_id',
			to_many: true,
			organize: by_lurid
		})
	}
});
