{"id":22666521,"url":"https://github.com/rhygg/hive-db","last_synced_at":"2025-04-12T09:53:03.660Z","repository":{"id":53016643,"uuid":"337635252","full_name":"rhygg/hive-db","owner":"rhygg","description":"A Nodejs key value storage database for mongodb, sqlite and Postgres!","archived":false,"fork":false,"pushed_at":"2021-05-17T06:44:59.000Z","size":112,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T09:52:53.645Z","etag":null,"topics":["database","databases","hive-db","keyv","keyvalue","mongodb","nodejs","npm","postgresql","postgresql-database","quick","sqlite","sqlite-database"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/rhygg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"rhydderchc","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-02-10T06:16:58.000Z","updated_at":"2022-01-28T10:40:21.000Z","dependencies_parsed_at":"2022-09-05T02:41:53.712Z","dependency_job_id":null,"html_url":"https://github.com/rhygg/hive-db","commit_stats":null,"previous_names":["rhydderchc/hive-db"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhygg%2Fhive-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhygg%2Fhive-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhygg%2Fhive-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhygg%2Fhive-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhygg","download_url":"https://codeload.github.com/rhygg/hive-db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550636,"owners_count":21122932,"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":["database","databases","hive-db","keyv","keyvalue","mongodb","nodejs","npm","postgresql","postgresql-database","quick","sqlite","sqlite-database"],"created_at":"2024-12-09T14:15:15.059Z","updated_at":"2025-04-12T09:53:03.637Z","avatar_url":"https://github.com/rhygg.png","language":"JavaScript","funding_links":["https://ko-fi.com/rhydderchc"],"categories":[],"sub_categories":[],"readme":"![hive-db](https://media.discordapp.net/attachments/790866153316679680/807265892408623104/0001-16485206787_20210205_203508_0000-removebg-preview.png?width=455\u0026height=455)\n## ChangeLog\n**Hive-db now has interactions based on the adapter you choose, so that you can swiftly use the whole module!**\n[Wiki for an in-dept guide](https://github.com/Rhydderchc/hive-db/wiki)\n\n# Hive-db\n\n### Hive-db is a persistent modular database to store data with ease, rather than complex structures.\n\n### Adapters\n1. `mongodb -\u003e hive.Mongo`\n2. `sqlite -\u003e hive.sqlite`\n3. `postgres -\u003e hive.Postgres`\n\n### An example of how it looks!\n```js\nconst hive = require('hive-db');\nconst db = hive.sqlite;\ndb.init('name',['Lason']);\ndb.get('name')\n// output =\u003e Lason\n\n/*\nArray Functionality in Hive-db\n*/\n\ndb.input('name','Tensor')\ndb.array('name');\n// output =\u003e Lason, Tensor\n\n```\n\n\n\n\n### Example with a discord.js bot\n\n```js\nconst Discord = require('discord.js');\nconst hive = require('hive-db');\nconst db = hive.sqlite;\n\n run = async (message, args, client) =\u003e{\n message.channel.send('Enter your name');\n db.init('name', args[0]);\n }\n\n//Trigger function using get.\n\nconst Discord = require('discord.js');\nconst db = require('hive-db');\n\n run = async (message, args, client) =\u003e{\n message.channel.send('Your name is \\t'+db.get('name'));\n }\n /*\n You can do only user based values that are unique for example, to remember\n the name of some users db.init(`name_${message.author.id}`, args[0]), because\n discord user ids are unique, same goes with guild values!\n */\n ```\n\n\n\n\n# Provided Functions as of now\n\n1. Initialize your key and value!\n```js\ndb.init('name',['Lason']);\n\n```\n2. Get the value stored in the key!\n```js\ndb.fetch('name')\n```\n3. Delete a key!\n```js\ndb.del('name')\n```\n4. Input an element into an array value.\n```js\ndb.push('name','Tensor')\n```\n5. Subtract a numeric value from a key storing a numeric value\n```js\ndb.subtract('age',1)\n// subtracting 21 from 1, where age(key) contains -\u003e 21\n```\n6.  Subtract a numeric value from a key storing a numeric value\n```js\ndb.add('age',1)\n// Adding 1 to 21, where age(key) contains -\u003e 21\n```\n7. Fetching all elements as an array\n```js\ndb.fetchArray('name')\n// output =\u003e Tensor, Lason\n```\n8. Checks if a key stores a `value` or is `null`\n```js\ndb.has('name')\n// output =\u003e true\n```\n9. Outputs the datatype of the stored value in a key.\n```js\ndb.datatype('age')\n// output =\u003e int\n```\n# Mongo-Db interaction with Hive-db\nYou can use both localhost and MongoDb altas uri's to connect to mongodb.\nHere is an example of its support:-\n```js\nconst hive = require('hive-db');\nconst mongo= new hive.Mongo(\"mongodb+srv://wyvern:thebestbot@cluster0.67lsz.mongodb.net\", \"JSON\", { useUnique: true });\nmongo.on(\"ready\", () =\u003e {\n    console.log(`Connected!`);\n    test();\n});\nmongo.on(\"error\", console.error);\nmongo.on(\"debug\", console.log);\nasync function test() {\n  mongo.init('age','21');\n  mongo.get('age')\n  //-\u003e 21\n  mongo.init('name','Lason');\n  mongo.get('name');\n  //-\u003e Lason\n}\n```\nCreating Tables using hive-db mongo interaction!\n```js\nconst db = require('hive-db');\nconst mongo= new db.Mongo(\"mongodb+srv://wyvern:thebestbot@cluster0.67lsz.mongodb.net\", \"JSON\", { useUnique: true });\nmongo.on(\"ready\", () =\u003e {\n    console.log(`Connected!`);\n    test();\n});\nmongo.on(\"error\", console.error);\nmongo.on(\"debug\", console.log);\nasync function test() {\n  const test = db.table('test');\n  test.init('slogan','hive-db is da best!')\n  test.get('slogan');\n  // output =\u003e hive-db is da best\n  // while if we use mongo.get('slogan') it won't work!\n  mongo.get('slogan');\n  // returns null!\n}\n```\n# Mongo Methods\n\nInitialize a value.\n```js\nmongo.init(\"foo\", \"bar\");\n```\nGet a value.\n```js\nmongo.get(\"foo\").then(console.log);\n//-\u003e bar\n```\nInput a value into an existing array.\n```js\nmongo.push(\"name\");\n// assuming that the key name has an array, for example [\"Lason\", \"Tensor\"]\n```\nAdd a value to a data(number) in a key\n```js\nmongo.add('age', 4)\n// adds 4 to the age\n```\nSubtract a value from a data(number) in a key\n```js\nmongo.subtract('age', 4)\n// subtracts 4 from the age\n```\nCreate data models!\n```js\nconst age = mongo.table('age')\nage.init('name', 'Lason')\nage.get('name').then(console.log);\n// -\u003e Lason!\n```\n**TIP**\nYou can use your own data table using a JSON base. Below stats an example using the key, data structure.\n```\n[\n{\n\"ID\":\"something\",\n\"data\":\"something\"\n}\n]\n```\nHive-db understands this without any external effort, and you don't even have to call the file anywhere in your code!\n```js\ndb.get(\"something\");\n//-\u003e give you something as the output!\n```\n# Postgres Methods\n\nYes **hive-db** offers postgres interaction! Isn't that super cool!\n\nConnecting to the postgres pool:\n```js\n{Postgres} = require('hive-db');\nconst db = new Postgres({\n   host: 'localhost',\n  user: 'postgres',\n  password: '1234',\n  database: 'myDatabase'\n})\n/*\nBasic paradigm\nnew Postgres({\n  config options, \n  table\n})\n*/\n```\n**Create new schemas using the postgres pool!**\n\n```js\n{Postgres} = require('hive-db');\nconst db = new Postgres({\n   host: 'localhost',\n  user: 'postgres',\n  password: '1234',\n  database: 'myDatabase'\n}, {\n  schema:'people' //schema name\n})\n\n```\n\n**get data**\n```js\nawait db.get('peope')\n```\n**init data**\n```js\nawait db.init('people', 'Jack');\n```\n**delete data**\n```js\nawait db.del('people', 'Lason');\n```\n**push data into an array**\n\n```js\nawait db.push('people', 'Tensor');\n```\n**Fetch data as an array!**\n```js\nawait db.fetchArray('people');\n// output =\u003e [Jack, Tensor]\n```\n**Search for a value in a key**\n```js\nawait db.search('people','Tensor')\n// output =\u003e true\n```\n\n## [Support Server](https://discord.gg/RTh79cwxxp) | [Documentation](https://hive-db.gitbook.io/docs/)\n\n# Sponsors!\n\n## [BytesToBits](https://discord.gg/bbPmhMMSyC)\n![Bytes To Bits](https://media.discordapp.net/attachments/774822256559915048/807614306623553546/BTBLogoColoredHead.png)\n\n# Reminder\nThe hive-db github repository is the development verision of hive-db.\n## Also\nCheck the [wiki](https://github.com/Rhydderchc/hive-db/wiki) for a guide.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhygg%2Fhive-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhygg%2Fhive-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhygg%2Fhive-db/lists"}