{"id":21277652,"url":"https://github.com/instafluff/comfydb","last_synced_at":"2025-07-31T10:08:02.702Z","repository":{"id":34983057,"uuid":"190447552","full_name":"instafluff/ComfyDB","owner":"instafluff","description":"Comfiest Way to Use A Database (MongoDB)!","archived":false,"fork":false,"pushed_at":"2023-09-26T19:17:20.000Z","size":114562,"stargazers_count":8,"open_issues_count":12,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-20T05:51:43.473Z","etag":null,"topics":["comfy","database","db","easy","easy-to-use","instafluff","intuitive","mongo","mongodb","query","search","storage","wrapper"],"latest_commit_sha":null,"homepage":null,"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/instafluff.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}},"created_at":"2019-06-05T18:27:31.000Z","updated_at":"2022-10-27T22:58:19.000Z","dependencies_parsed_at":"2024-11-20T21:15:18.931Z","dependency_job_id":null,"html_url":"https://github.com/instafluff/ComfyDB","commit_stats":{"total_commits":52,"total_committers":4,"mean_commits":13.0,"dds":0.4807692307692307,"last_synced_commit":"0468d39721f6a34c095ed8b54fe36f2715eee5e6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instafluff%2FComfyDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instafluff%2FComfyDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instafluff%2FComfyDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instafluff%2FComfyDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instafluff","download_url":"https://codeload.github.com/instafluff/ComfyDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225708290,"owners_count":17511635,"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":["comfy","database","db","easy","easy-to-use","instafluff","intuitive","mongo","mongodb","query","search","storage","wrapper"],"created_at":"2024-11-21T10:06:38.366Z","updated_at":"2024-11-21T10:06:39.192Z","avatar_url":"https://github.com/instafluff.png","language":"JavaScript","funding_links":["https://github.com/sponsors/instafluff"],"categories":[],"sub_categories":[],"readme":"# ComfyDB\nThe Comfiest Way to Use a Database\n\n**ComfyDB** is a ***SUPER EASY AND INTUITIVE*** interface to a database *(Currently supports MongoDB)* so you don't have to keep looking up the documentation.\n\nComfyDB abstracts away the specific syntax for working with databases so that it's intuitive and easy to use for common scenarios while benefitting from search, performance, redudancy of a full-fledged database.\n\nIt also takes care of mundane tasks like setting and maintaining `createdAt` and `updatedAt` fields for each object entry.\n\n```javascript\nawait ComfyDB.Store( \"user1\", { username: \"Instafluff\", profile: \"Comfiest Coder and Mug Chef!\", cakes: 0 } );\nawait ComfyDB.Get( \"user1\" );\n\nawait ComfyDB.Search( { sortBy: \"createdAt\", sort: \"desc\", limit: 5, start: 10, where: { author: { beginsWith: \"instaf\" } } }, \"blog-posts\" );\nawait ComfyDB.Count( { where: { text: { contains: \"lasagna\" } } }, \"blog-posts\" );\n\nawait ComfyDB.Increment( \"cakes\", { by: 2, where: { username: { equals: \"instafluff\" } } } );\nawait ComfyDB.Decrement( \"hitpoints\", { by: 30, where: { party: { equals: \"A\" } } }, \"game-stats\" );\n\nawait ComfyDB.Delete( \"item_42\" );\nawait ComfyDB.DeleteAll( { where: { isEnemy: { is: true }, hitpoints: { \"\u003c\": 0 } } }, \"game-stats\" );\n```\n\n## Instafluff ##\n\u003e *Like these projects? The best way to support my open-source projects is by becoming a Comfy Sponsor on GitHub!*\n\n\u003e https://github.com/sponsors/instafluff\n\n\u003e *Come and hang out with us at the Comfiest Corner on Twitch!*\n\n\u003e https://twitch.tv/instafluff\n\n#### ComfyDB Requirements\nComfyDB requires a MongoDB instance to connect to.\n\nHere are three ways for you to setup an instance of MongoDB:\n\n1. Run a self-contained instance running on NodeJS via [ComfyMongoDB](https://www.github.com/instafluff/ComfyMongoDB) *(Recommended for developers)*\n2. Install [MongoDB Community Edition](https://docs.mongodb.com/manual/administration/install-community/) as a service on your computer *(Recommended for beginners)*\n3. Use a cloud-hosted MongoDB instance with [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) *(Recommended for companies and production)*\n\n## Instructions ##\n1. Install `comfydb`\n```\nnpm install comfydb --save\n```\n\n2. Connect to a MongoDB database and store, retrieve, search data\n```javascript\nconst ComfyDB = require( \"comfydb\" );\n// Wrap in async for back-compat in case top-level async/await is not supported\n(async () =\u003e {\n    try {\n        await ComfyDB.Connect( { url: \"mongodb://localhost:27017\", dbname: \"ComfyDB\" } );\n\n        // Sample users\n        await ComfyDB.Store( \"user1\", { username: \"Instafluff\", website: \"https://www.instafluff.tv\", profile: \"Comfiest Coder and Mug Chef!\" } );\n        await ComfyDB.Store( \"user2\", { username: \"Fluffington\", profile: \"Fluffy, Yellow, Hamsterbear.\" } );\n        await ComfyDB.Store( \"user3\", { username: \"Teapup\", profile: \"Semi-licensed rainbow skittle tricycle pupper. I'm the greatest!\" } );\n\n        // Get user3\n        let user3 = await ComfyDB.Get( \"user3\" );\n        console.log( user3 );\n\n        // Get all users with \"fluff\" in the username\n        let fluffUsers = await ComfyDB.Search( { sortBy: \"username\", sort: \"asc\", where: { username: { contains: \"fluff\" } } } );\n    \tconsole.table( fluffUsers );\n    }\n    catch( err ) {\n        console.error( err );\n    }\n})();\n```\n\n## Functions ##\n\n```javascript\n// --- Configuration ---\n\n// Connect to a database on MongoDB\nawait ComfyDB.Connect( options = { url: \"mongodb://localhost:27017\", dbname: \"comfyDB\" } );\n\n// Check if we are connected to a database\nComfyDB.IsConnected();\n\n// Close connection to the database\nComfyDB.Close();\n\n\n\n// --- Data ---\n\n// Insert/Update JSON object entry by key (e.g. userID, username, timestamp, ... )\nawait ComfyDB.Store( key, data, collection = \"ComfyDefault\" ); // ComfyDB.Save() also works\n\n// Retrieve object entry by key\nawait ComfyDB.Get( key, collection = \"ComfyDefault\" );\n\n// Retrieve array of object entries based on search options\nawait ComfyDB.Search( options = { sortBy: \"createdAt\", sort: \"asc\", limit: 100, start: 0, where: null, key: null }, collection = \"ComfyDefault\" );\n\n// Delete object entry by key\nawait ComfyDB.Delete( key );\n\n// Delete object entries based on search options\nawait ComfyDB.DeleteAll( options = { where: null, key: null }, collection = \"ComfyDefault\" );\n\n// Increment a field in object entries matching search options\nawait ComfyDB.Increment( field, options = { where: null, key: null }, collection = \"ComfyDefault\" );\n\n// Decrement a field in object entries matching search options\nawait ComfyDB.Decrement( field, options = { where: null, key: null }, collection = \"ComfyDefault\" );\n\n// Count the number of object entries matching search options\nawait ComfyDB.Count( options = { where: null, key: null }, collection = \"ComfyDefault\" );\n\n\n\n// --- Collections ---\n\n// Get a full list of collections\nawait ComfyDB.Collections();\n\n// Check if a collection exists\nawait ComfyDB.HasCollection( collection );\n\n// Delete a collection\nawait ComfyDB.DeleteCollection( collection );\n```\n\n## How to Use Search Options ##\nDefining the search conditions for ComfyDB functions is done by setting up a configuration object.\n\n#### Search Options Fields ####\n  - **sortBy** (orderBy) *(Only in **ComfyDB.Search**)*\n    - The name of the stored data object entry's field to use for the sort. Defaults to `createdAt`.\n  - **sort** *(Only in **ComfyDB.Search**)*\n    - `asc` or `desc` for ascending or descending sort based on the `sortBy` field. Defaults to `asc`.\n  - **limit** (count) *(Only in **ComfyDB.Search**)*\n    - Maximum number of results, used for pagination. Defaults to `100`.\n  - **start** *(Only in **ComfyDB.Search**)*\n    - Starting index for the results, used for pagination. Defaults to `0`.\n  - **by** *(Only in **ComfyDB.Increment** and **ComfyDB.Decrement**)*\n    - Amount to increment or decrement the field's value by for all matching data object entries. Defaults to `1`.\n  - **where**\n    - Refines the search based on values inside the stored data object entries. Defaults to `null`.\n\n#### Where Object ####\nThe inner `where` object helps fine-tune the search based on aspects of the stored data object entries.\n\nAll keys inside this object adds to the search conditions (e.g. `username`) using a search operator (e.g. `equals`). Keys are case-sensitive. Operators are not case-sensitive.\n\n**Operators**\n  - **equals** (eq, equal, equals, is, isEqual, isequalto, =)\n  - **not** (ne, notequals, notequal, doesntequal, isnot, isnt, isnotequal, isnotequalto, !, !=, \u003c\u003e)\n  - **before** (lessthan, lt, \u003c)\n  - **after** (after, greaterthan, gt, \u003e)\n  - **contains** (includes)\n  - **startsWith** (starts, begins, beginswith, prefix)\n  - **endsWith** (ends, suffix)\n\n#### Search Option Examples ####\n\n```javascript\n// Retrieving the most recent 5 entries where the score is higher than 50 points\nlet scores = await ComfyDB.Search( { sortBy: \"updatedAt\", sort: \"desc\", limit: 5, start: 0, where: { score: { \"\u003e\": 50 } } } );\n\n// Decrementing hitpoints for all of party A's members in the Game-Stats collection\nawait ComfyDB.Decrement( \"hitpoints\", { by: 30, where: { party: { equals: \"A\" } } }, \"game-stats\" );\n\n// Deleting all enemies with HP \u003c 0 in the Game-Stats collection\nawait ComfyDB.DeleteAll( { where: { isEnemy: { is: true }, hitpoints: { \"\u003c\": 0 } } }, \"game-stats\" );\n```\n\n## Credits ##\nThank you too all the participants of this project!\n\n**DutchGamer46, Instafluff, Instafriend, ChatTranslator, SourBeers, zivivi1, That_MS_Gamer, jjanders85, simrose4u, Kyoslilmonster, sparky_pugwash, i_am_from_mars, julieee22, codingkatie, jellydance, LilyHazel, lewdmelon, Luxadin_, FuriousFur, sethorizer, Ella_Fint, DEAD_P1XL, Psychosys82, malfunct, UppahahAA, Stay_Hydrated_Bot, holloway87, RIKACHET, SullyGnome, Gyrojett, roberttables, ReaperofTerror, BigShoe, GoonPontoon, dot_commie, retro_crt, rhonin52, Clarkio, mholloway24, ObsidianTalon, jFeliWeb, Maayainsane, LuckyFeathersGames, WolvesGamingDen, adamisbest1231, otistav, AccordingToBo, TheHugoDahl, CodeRushed, grassgrow, EndlessMoonfall, AntiViGames, nopogo_tv, smilesandtea, Clearest_Sky, tinybolt9889, falco_online, DrJavaSaurus, MsSaltyGiggles, poppybox, infinitepharaoh_, merkurrz, jawibae, EvilCanadian, cmjchrisjones, theLeprosyy, Alca, Schattenheld0u0, codephobia, Zuulmofo, Granah, Cj_crew, donaldwm, Jwh1o1, ThatNerdViolet, phrakberg, phoenixfirewingz, Aririal, BungalowGlow**\n\nThanks to everyone that helped design the ComfyDB functions!\n\n**MacABearMan, wietlol, Ella_Fint, EarthToRaymond, Danicron5, That_MS_Gamer, Gilokk0, Deitypotato, Instafluff, Alca, DutchGamer46, Instafriend, ChatTranslator, sethorizer, LuRiMer313, losthewar, TheHugoDahl, sayomgwtf, simrose4u, oomariaoo, LilyHazel, Eolios, CriticalKnit, MerlinLeWizard, Breci, smilesandtea, nallaj, codephobia, sausage_toes, DEAD_P1XL, Talk2meGooseman, Stay_Hydrated_Bot, merkurrz, BooobieTrap, codingkatie, DevMerlin, DarrnyH, BaconBastrd, JamesFiteMeIRL, Luxadin_, stresstest, sparky_pugwash, adamisbest1231, MsSaltyGiggles, SourBeers, neniltheelf, napkats, apocalypse28064212, DeeNugLife, HeyOhKei, BEARabilityPH, jjanders85, RIKACHET, LANiD, ItsLittany, lukepistachio, Jikochi, julieee22, Underground_Violet_Doggo, MrLiveCrash, tiger_k1ng, EndlessMoonfall, ItsTheRealKaz, MisakaGUN, Hardcore_Henny, Psychosys82, TERENCEBE, Jwh1o1, jawibae, MalForTheWin, gamemodeon232, Lunnaku, itsDeke**\n\nThank you to everyone who helped make ComfyDB searchable and sortable!\n\n**That_MS_Gamer, MacABearMan, Instafluff, Gilokk0, Instafriend, ChatTranslator, Neo_TA, sethorizer, Optik_Nerve, TheGeekGeneration, Alca, guthron, TheHugoDahl, pipskidoodle, sayomgwtf, NorthernAurora2018, ExactlyMay, simrose4u, donaldwm, HonestDanGames, csharpfritz, holloway87, MsSaltyGiggles, LuRiMer313, jawibae, merkurrz, BeaverBoyB, LilyHazel, arnab345madd, SourBeers, Msomele, chiderzz, SaltPrincessGretchen, MalForTheWin, EgoAnt, nallaj, Stay_Hydrated_Bot, RiotMakr, DutchGamer46, Underground_Violet_Doggo, Eolios, smilesandtea, DarrnyH, pookiepew, gamesaregreat808, JBRedPhoenix, CyberNinjaGaming_UK, sparky_pugwash, koralina211, roberttables, DevMerlin, lewdmelon, sorskoot, CodeNJoy, Succatash, SimmeringSoupPot, FuriousFur, zivivi1, DEAD_P1XL, Dreadoosa, Jadro02, filipmanzi, Shaggz13, Luxadin_, minxyrose, Psychosys82, danteundersaturn, KitAnnLIVE, thegooseofwild**\n\nThank you to everyone who helped build the first working version 1.0.1!\n\n**MacABearMan, Instafriend, LilyHazel, Instafluff, Gilokk0, ChatTranslator, That_MS_Gamer, fydo, wietlol, simrose4u, ArliGames, Dreadoosa, roberttables, donaldwm, sethorizer, csharpfritz, TheHugoDahl, ancientcoder, theMichaelJolley, mordzuber, mholloway24, Stelzi79, Thrennenne, AndresAmaris, sorskoot, Grid21, SvavaBlount, nallaj, itsDeke, pipskidoodle, DutchGamer46, violettepanda, sparky_pugwash, FuriousFur, MerlinLeWizard, Bjwhite211, bachner, DevMerlin, senatorcalder, julieee22, KitAnnLIVE, MatthewDGroves, BungalowGlow, smilesandtea, Undinen, Underground_Violet_Doggo, DEAD_P1XL, ShadowNeverSeen, LANiD, Kyoslilmonster, pookiepew, gekophetweb, Kevin_C_Melsop, FulltimeDreamer_, Ob_stealth1, KassidyKW18, Cold_Earth_, theluckyseven17, julian992, MinoGozzo, imjustafnagirl, twdjesuslover, phoenixfirewingz, the7goonies, quqco, Emily_is_PogChamp, silverpocket51, SleepyMia, thementalcobra, kev40k, MLGBlackbeard, apoketo, Tomcii, JonGood, Miffyasha, SIeepyMia, KageNoTsuma, dragonhyperking, TheHungerService, ExactlyMay, adamisbest1231, Alca, WolvesGamingDen, harugawada, Luxadin_, swolemaz, CorrelR, hug3fan14, Jwh1o1, CriticalKnit, malfunct, mofumoku, gamemodeon232, bscolaro, HologramDream, EnesOzdemirTV, lewdmelon, Xalent, Maayainsane, Lander03xD, rotaidar, Cloudhun, Rosuav, SoG_Cuicui, GlitterholicDreamz, fikapaus, shadowcraft5, TheJollyMercenaryArt, superandi23, holloway87, AllanJLA, SodarCZ, HeyOhKei, TheSkiDragon, DarrnyH, shinageeexpress, AP4TV, Chibigirl24**\n\nThank you to all the friends who helped redesign ComfyDB into its v2 form!\n\n**TODO: Need to Get Chatters List from Instafluff Stream March 31, 2020**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstafluff%2Fcomfydb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstafluff%2Fcomfydb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstafluff%2Fcomfydb/lists"}