{"id":15572940,"url":"https://github.com/lostintime/io-ts-bson","last_synced_at":"2026-04-29T17:40:28.794Z","repository":{"id":62917140,"uuid":"561732666","full_name":"lostintime/io-ts-bson","owner":"lostintime","description":"io-ts codecs for bson types","archived":false,"fork":false,"pushed_at":"2022-11-07T18:32:13.000Z","size":178,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T20:03:54.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostintime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-04T11:15:43.000Z","updated_at":"2023-05-26T06:25:52.000Z","dependencies_parsed_at":"2022-11-09T04:15:14.430Z","dependency_job_id":null,"html_url":"https://github.com/lostintime/io-ts-bson","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostintime%2Fio-ts-bson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostintime%2Fio-ts-bson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostintime%2Fio-ts-bson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostintime%2Fio-ts-bson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostintime","download_url":"https://codeload.github.com/lostintime/io-ts-bson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246149882,"owners_count":20731405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T18:08:53.396Z","updated_at":"2026-04-29T17:40:28.725Z","avatar_url":"https://github.com/lostintime.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `io-ts` codecs for `bson` types\n\nThis package provides [io-ts](https://github.com/gcanti/io-ts) codecs for [bson](https://github.com/mongodb/js-bson) data types.\n\n## Installation\n\n```sh\nnpm install --save io-ts-bson\n```\n\n## Usage\n\nDatabase entities may be defined using the `io-ts-bson` types and then decoded/encoded.\n\n```ts\nimport * as bson from 'bson';\nimport * as t from 'io-ts';\nimport * as bt from 'io-ts-bson';\n\nexport const UserProfile = t.type(\n  {\n    _id: bt.ObjectId,\n    name: t.string,\n    createdAt: bt.date,\n  },\n  'UserProfile',\n);\nexport type UserProfile = t.TypeOf\u003ctypeof UserProfile\u003e;\n\nexport const loadUserProfile = async (id: string) =\u003e {\n  const user = await db.collection('users').findOne({\n    _id: bson.ObjectId.createFromHexString(id),\n  });\n\n  return UserProfile.decode(user);\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostintime%2Fio-ts-bson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostintime%2Fio-ts-bson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostintime%2Fio-ts-bson/lists"}