A package to generate 12 bytes Hex String for MongoDB Object Id
npm install mongo-oid

Updates:
- Typescript Support Added
``bash`
npm install mongo-oid
or
`bash`
yarn add mongo-oid
Below is the Example use case for upserting Data. (Update if id exists or create with the following Object Id)
`tsx
import { oid } from "mongo-oid";
function From({ user }: { user?: UserType }) {
const [doc, setDoc] = useState<{
id: string;
name: string;
}>({
id: user ? user.id : oid(),
name: user ? user.name : "",
});
console.log(oid());
// "f2a1b3c4d5e6a7b8c9d0e1f2"
return ;
}
export default Form;
``
Contributing on this project is always welcome! Just fork, update, push to your respective branch and make a pull request after testing. Make sure to open an issue before contribute.
MIT © Abdur Rahman