Skip to content

Instantly share code, notes, and snippets.

View moiri's full-sized avatar

Simon Maurer moiri

  • University of Bern
  • Bern
View GitHub Profile
@moiri
moiri / backend.ts
Last active April 24, 2024 06:48
Type Conversions from String to MongoDB ObjectId
import { ObjectId } from 'mongodb';
/* Use this to extend any interface with an `_id` property of type OID */
export type TWithOid<T extends {}> = T & {
_id: ObjectId;
};
/**
* Replaces a string property with the same property of type ObjectId.

Keybase proof

I hereby claim:

  • I am moiri on github.
  • I am moiri (https://keybase.io/moiri) on keybase.
  • I have a public key ASDOcohcX2INLSjRvNbHhLkasrj03g76UPo2O1Lws8GtnQo

To claim this, I am signing this object: