bergere-enchantee / src /lib /server /db /user-collection.ts
coyotte508's picture
coyotte508 HF staff
♻️ Migrate pictures to Object Storage
142fc6a
raw
history blame contribute delete
No virus
462 Bytes
import type { User } from '$lib/types/User';
import type { Collection, Db, MongoClient } from 'mongodb';
export function createUserCollection(db: Db, client: MongoClient): Collection<User> {
const coll = db.collection<User>('users');
client.on('open', () => {
coll
.createIndex(
{
email: 1
},
{
unique: true,
collation: {
locale: 'en',
strength: 1
}
}
)
.catch(console.error);
});
return coll;
}