{"id":26267227,"url":"https://github.com/oslabs-beta/anpan","last_synced_at":"2025-04-30T19:08:25.644Z","repository":{"id":221200293,"uuid":"751985821","full_name":"oslabs-beta/anpan","owner":"oslabs-beta","description":"A Redis OM for Bun","archived":false,"fork":false,"pushed_at":"2024-02-29T15:03:26.000Z","size":4787,"stargazers_count":39,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"prod","last_synced_at":"2025-04-30T19:06:50.949Z","etag":null,"topics":["bun","library","om","redis","redis-client"],"latest_commit_sha":null,"homepage":"https://breadisbuns.github.io/","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/oslabs-beta.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"open-source-labs","custom":["https://donorbox.org/donations-to-oslabs-inc"]}},"created_at":"2024-02-02T19:01:32.000Z","updated_at":"2025-04-20T21:24:50.000Z","dependencies_parsed_at":"2024-02-24T22:25:37.266Z","dependency_job_id":"6cb6892a-7fef-42a7-b7ef-02c1c21f8293","html_url":"https://github.com/oslabs-beta/anpan","commit_stats":null,"previous_names":["oslabs-beta/anpan"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2Fanpan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2Fanpan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2Fanpan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2Fanpan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oslabs-beta","download_url":"https://codeload.github.com/oslabs-beta/anpan/tar.gz/refs/heads/prod","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251767192,"owners_count":21640468,"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":["bun","library","om","redis","redis-client"],"created_at":"2025-03-14T04:16:09.726Z","updated_at":"2025-04-30T19:08:25.605Z","avatar_url":"https://github.com/oslabs-beta.png","language":"TypeScript","funding_links":["https://github.com/sponsors/open-source-labs","https://donorbox.org/donations-to-oslabs-inc"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/oslabs-beta/anpan/dev/assets/anpan-logo.png\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eanpan\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003eA Redis OM for Bun\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\u003ca href=\"https://breadisbuns.github.io/\"\u003eVisit our Website\u003c/a\u003e\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003eCheckout our library:\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/@breadisbuns/anpan\"\u003e\u003cimg src=\"https://img.shields.io/badge/npm-CB3837?style=for-the-badge\u0026logo=npm\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003eRead our Medium Launch Article:\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://medium.com/@anpanomofficial/anpan-a-redisdb-om-for-bun-42a89af745fa\"\u003e\u003cimg src=\"https://img.shields.io/badge/Medium-12100E?style=for-the-badge\u0026logo=medium\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/redis-%23DD0031.svg?\u0026style=for-the-badge\u0026logo=redis\u0026logoColor=white\" /\u003e\n\u003cimg src=\"https://img.shields.io/badge/bun-282a36?style=for-the-badge\u0026logo=bun\u0026logoColor=fbf0df\" /\u003e\n\u003cimg src=\"https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge\u0026logo=typescript\u0026logoColor=white\" /\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n## Table of Contents\n\n1. [Description](#description)\n2. [Getting Started](#get-started)\n3. [Query](#query)\n4. [Additional Methods](#additional-methods)\n5. [Open Source Information](#open-source-information)\n6. [Authors](#authors)\n7. [License](#license)\n\n## \u003ca name='description'\u003e\u003c/a\u003e Description\n\n\u003cstrong\u003eanpan\u003c/strong\u003e is a lightweight Redis Object Mapper (OM) library built for the Bun runtime. Bun is an up-and-coming runtime environment for Javascript and Typescript that replaces Node.js. Bun’s v1.0 was released on September 8th, 2023, and has since demonstrated that they are 4x faster than Node.js and 2x faster than Deno. Since their release, many developers, like those working with a Redis database, are seeking to run their code in Bun for its speed and efficiency. Unfortunately, no Redis-specific library currently runs in the Bun runtime environment. anpan is a Redis OM that bridges the gap for developers working in Bun with a Redis database. anpan works to abstract away hard-to-understand and write syntax, that, when paired with the \u003cstrong\u003e\u003ca href=\"https://breadisbuns.github.io/\"\u003eanpan webpage\u003c/a\u003e\u003c/strong\u003e, helps even a new user learn Redis right away. anpan brings the familiarity of other databases and libraries, like MongoDB and Mongoose, allowing other NoSQL database users easy access and navigation.\n\n## \u003ca name='get-started'\u003e\u003c/a\u003e Getting Started\n\nBe sure that you have the [Bun](https://bun.sh/docs/installation) runtime installed and configured.\n\n### Quick Start\n\nIn your application, install the package from the NPM [module](https://www.npmjs.com/package/@breadisbuns/anpan).\n\n```bash\nbun i @breadisbuns/anpan\n```\n\nNext, require in the anpan module into your codebase.\n\n```typescript\nconst { Schema, Repository } = require('@breadisbuns/anpan');\n```\n\n### Connect to your Database\n\nOpen a connection by requiring in createClient from Redis with the Redis cloud link found in your \u003ca href=\"https://redis.com/\"\u003eRedis dashboard\u003c/a\u003e, and using the connect method from Redis.\n\n```typescript\nconst { createClient } = require('redis');\n\nconst { client } = createClient({\n  password: 'YOUR PASSWORD HERE',\n  socket: {\n    host: 'LINK TO CLOUD',\n    port: 12179,\n  },\n});\n\nawait client.connect().then(console.log('Connected to Redis'));\n```\n\n### Define Your Schema\n\nNow, you can define your schema with the Schema method as shown below or by utilizing the schema generator on the \u003ca href='https://breadisbuns.github.io/'\u003eanpan webpage\u003c/a\u003e:\n\n```typescript\nconst bakerySchema = new Schema('bakery', {\n  name: { type: 'string', isRequired: true },\n  owner: { type: 'string', isRequired: true },\n  dateCreated: { type: 'date' },\n  bakeryNum: { type: 'number' },\n  location: { type: 'point' },\n  bunsOffered: { type: 'string[]' },\n});\n```\n\nValid Datatypes include:\n\n- boolean\n- date\n- number\n- number[]\n- point\n- string\n- string[]\n- text\n\n### Create Your Repository\n\nSet up a repository by invoking the Respository method with your schema name and client:\n\n```typescript\nconst theBakeries = new Repository(bakerySchema, client);\n```\n\n### Add to Your Repository\n\nYou can now add to the repository by creating entities with your data as outlined in your schema:\n\n```typescript\nconst anpanBun = {\n  name: 'Buns Unlimited',\n  owner: 'May',\n  dateCreated: new Date(2023, 1, 14),\n  bakeryNum: 1,\n  location: { longitude: 1, latitude: 1 },\n  bunsOffered: ['Hotcross', 'Hotdog', 'Steamed'],\n};\n\nconst mayBakery = await theBakeries.save(anpanBun); //adds entity to Redis database\n```\n\n### Make a Query\n\nNow, you can search and find items in your model. For example, if you wanted to look at the buns offered at May's Buns Unlimited bakery, you can fetch by ULID:\n\n```typescript\n//---Targeting a ULID---\nconst mayULID = mayBakery.entityKeyName;\nconsole.log(mayULID); //displays ULID in your console to fetch\n\n//---Fetching w/ULID---\nlet fetchMay = await theBakeries.fetch(mayULID);\nconsole.log(fetchMay); //will log fetched mayBakery\n```\n\nCongratulations! You have successfully imported anpan, connected to Redis client, created a schema and a repository, added an entitiy to your Redis database, and fetched May's bakery. Explore the rest of the README.md for more detailed instructions on how to use anpan.\n\n## \u003ca name='query'\u003e\u003c/a\u003e Query\n\nAll queries in anpan are performed using repositories. All query methods are listed below:\n\n- getAllEntities\n\n```typescript\nconst allBakeries = await theBakeries.getAllEntities();\nconsole.log(allBakeries); //Will log all stored bakeries!\n```\n\n- getByString\n\n```typescript\nconst findString = await theBakeries.getByString('Kevin');\nconsole.log(findString); //Will log all bakeries containing queried string\n```\n\n- getByNumber\n\n```typescript\nconst findNumber = await theBakeries.getByNumber(1);\nconsole.log(findNumber); //Will log all bakeries containing queried number\n```\n\n## \u003ca name='additional-methods'\u003e\u003c/a\u003e Additional Methods\n\nAdditional features and methods include:\n\n- update with save()\n\n```typescript\n//---Update with save()---\nfetchMay.bunsOffered.push('Melonpan');\nfetchMay = await theBakeries.save(fetchMay);\nconsole.log(fetchMay); //Will log with additional bun offered\n```\n\n- remove with ULID\n\n```typescript\n//---Remove w/ULID---\nconst dillonULID = dillonBakery.entityKeyName;\nconst deleteDillon = await theBakeries.remove(dillonULID);\nconsole.log(deleteDillon); //Will log undefined\n```\n\n- expire with ULID\n\n```typescript\n//---Expire w/ULID---\nconst kellsyULID = kellsyBakery.entityKeyName;\nconst expireKellsy = await theBakeries.expire(kellsyULID, 10); //Will show countdown in RedisInsight, logs undefined after expiration\n```\n\n## \u003ca name='open-source-information'\u003e\u003c/a\u003e Open Source Information\n\nIf you would like to contribute to our product, let us know! Below are features and methods we would have liked to implement in our library. If you would like to propose a new feature or method, send us a message.\n\n### Contribution Guidelines\n\nTo contribute, fork and clone our repository. Once set up, any changes will need to be approved via Pull Requests. We ask that you include as much information and documentation for any changes made when you create a PR.\n\n### Running the library tests in dev mode\n\nOnce cloned, run the command:\n\n```bash\nbun test\n```\n\n### Features and Methods:\n\n| Feature                         | Status |\n| ------------------------------- | ------ |\n| Point search functionality      | 🙏🏻     |\n| Pagination search functionality | 🙏🏻     |\n| Sorting functionality           | 🙏🏻     |\n\n- ✅ = Ready to use\n- ⏳ = In progress\n- 🙏🏻 = Looking for contributors\n\n## \u003ca name='authors'\u003e\u003c/a\u003e Authors\n\n- ### May Wilcher\n  \u003ca href=\"https://github.com/rehcliw\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/may-wilcher/\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e\n- ### Kellsy Nava-López\n  \u003ca href=\"https://github.com/kelsIam\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/kellsy-nava-l%C3%B3pez/\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e\n- ### Dillon Hale\n  \u003ca href=\"https://github.com/HailsD\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/dillon-hale/\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e\n- ### Kevin Murphy\n  \u003ca href=\"https://github.com/murph212\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.linkedin.com/in/kevin-murphy-5173701b/\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\n## \u003ca name='license'\u003e\u003c/a\u003e License\n\nThis product is licensed under the MIT License - see the LICENSE file for details.\n\nThis is an open-source product.\n\nThis product is accelerated by \u003ca href=\"https://opensourcelabs.io/\"\u003eOS Labs.\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2Fanpan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foslabs-beta%2Fanpan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2Fanpan/lists"}