{"id":29405039,"url":"https://github.com/tgoins/natsuki-db","last_synced_at":"2026-04-06T09:33:37.517Z","repository":{"id":57308904,"uuid":"118992013","full_name":"tgoins/natsuki-db","owner":"tgoins","description":"Database module for Natsuki Discord bot.","archived":false,"fork":false,"pushed_at":"2018-02-07T00:06:14.000Z","size":319,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T22:09:02.436Z","etag":null,"topics":["database","discord","nodejs","postgresql","typeorm","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgoins.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":"2018-01-26T01:58:21.000Z","updated_at":"2018-10-27T22:36:23.000Z","dependencies_parsed_at":"2022-09-14T17:53:36.591Z","dependency_job_id":null,"html_url":"https://github.com/tgoins/natsuki-db","commit_stats":null,"previous_names":["tannerz28/natsuki-db"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tgoins/natsuki-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgoins%2Fnatsuki-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgoins%2Fnatsuki-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgoins%2Fnatsuki-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgoins%2Fnatsuki-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgoins","download_url":"https://codeload.github.com/tgoins/natsuki-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgoins%2Fnatsuki-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31466629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["database","discord","nodejs","postgresql","typeorm","typescript"],"created_at":"2025-07-10T21:12:12.343Z","updated_at":"2026-04-06T09:33:37.512Z","avatar_url":"https://github.com/tgoins.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NatsukiDB\nWriting your bot's database can be a pain. As you develop your bot, you will constantly modify your schema, risking losing data if you don't migrate it.\nNatsukiDB solves that issue by allowing you to have a premade database ready to be thrown into your bot. It is designed to store all the data you need plus more.\n\nNatsukiDB is the database module for the Natsuki Discord bot, made public so anyone can have a premade database for their bot as well.\n\nThe purpose of the database being its own module, is to make the parent bot more modular, like a micro-service for the bot. It also allows the database to easily be reused in a web interface for the bot, using Angular 5.\n\nFeel free to suggest new entities/columns, or even create a Pull Request to add your own changes. If I like it, I may even implement it into the Natsuki bot.\n\n## Prerequisites\n - Node.js \u003e 7.0.0, Recommended \u003e 8.0.0.\n - PostgreSQL \u003e 9.0.\n - A Discord bot running on Discord.js.\n - (optional [for now]) Redis. Will be used in a future update.\n\n## Installation\n```sh\n$  npm i -s natsuki-db\n```\n\n## Usage\nFirst we need to import the module.\n```javascript\nimport { connect, Connection } from 'natsuki-db'\n```\n\nAt the basic level, we need to connect to the database, so we import the `connect` method. The connect method returns a Promise of type `Connection` so we can import that also.\n\nThe `connect` method expects an object with a few connection options: host, username, password, database, and port.\n\n```javascript\n// Preferably, you should store these externally, like in a json file. This is just for example.\nconst options = {\n  host: 'localhost'\n  username: 'postgres',\n  password: '',\n  database: 'postgres',\n  port: 5432\n}\n\nconnect(options)\n  .then((connection: Connection) =\u003e {\n    // Connection successful, woohoo!\n  })\n  .catch((error: Error) =\u003e {\n    // Handle error\n})\n```\n\nAlternatively, you can use `async`/`await` to connect.\n\n```javascript\nconst connection: Connection = await connect(options)\n```\n\nAll methods in the module return a promise.\n\nThe module itself does not handle any exceptions, it simply executes something and immediately returns the result. You will have to handle the exceptions on your end.\n\n## Tables\nThere are several tables in the database. NatsukiDB uses a relational database, PostgreSQL, allowing the database to be composed of several small tables for the fastest queries.\n\n### User\n\nGlobal information about the user.\n\n#### UserBalance\n\nUser's credit balance and net worth.\n\n#### UserLevel\n\nUser's level and XP.\n\n#### UserProfile\n\nUser's profile settings.\n\n#### UserGuild\n\nUser's information about the guilds they are in.\n\n#### UserReputation\n\nUser's reputation, given from other members.\n\n#### UserWarning\n\nUser's warning logs from all servers they received a warning.\n\n#### UserKick\n\nUser's kick logs from all servers they were kicked from.\n\n#### UserBan\n\nUser's ban logs from all servers they were banned from.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgoins%2Fnatsuki-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgoins%2Fnatsuki-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgoins%2Fnatsuki-db/lists"}