{"id":29089390,"url":"https://github.com/nocapscripts-fivem/fivemongo","last_synced_at":"2026-04-13T13:01:56.567Z","repository":{"id":301331460,"uuid":"1008925443","full_name":"NoCapScripts-FiveM/fivemongo","owner":"NoCapScripts-FiveM","description":"MongoDB wrapper for FiveM server environment.","archived":false,"fork":false,"pushed_at":"2025-07-01T06:30:57.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-02T03:58:55.452Z","etag":null,"topics":["database","esx-framework","esx-legacy","fivem","lua","mongodb","mongodb-database","qbcore","qbcore-framework","typescript","wrapper"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoCapScripts-FiveM.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,"zenodo":null}},"created_at":"2025-06-26T09:56:21.000Z","updated_at":"2025-07-01T06:31:00.000Z","dependencies_parsed_at":"2025-06-26T10:43:18.844Z","dependency_job_id":null,"html_url":"https://github.com/NoCapScripts-FiveM/fivemongo","commit_stats":null,"previous_names":["nocapscripts-fivem/fivemongo"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/NoCapScripts-FiveM/fivemongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoCapScripts-FiveM%2Ffivemongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoCapScripts-FiveM%2Ffivemongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoCapScripts-FiveM%2Ffivemongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoCapScripts-FiveM%2Ffivemongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoCapScripts-FiveM","download_url":"https://codeload.github.com/NoCapScripts-FiveM/fivemongo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoCapScripts-FiveM%2Ffivemongo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31753551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","esx-framework","esx-legacy","fivem","lua","mongodb","mongodb-database","qbcore","qbcore-framework","typescript","wrapper"],"created_at":"2025-06-28T04:01:45.762Z","updated_at":"2026-04-13T13:01:56.550Z","avatar_url":"https://github.com/NoCapScripts-FiveM.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍋 MongoDB Wrapper for FiveM\n\n\u003e ⚠️ **This resource is in active development.** Bugs and frequent updates are expected. Feedback and contributions are welcome!\n\nA modern, lightweight **MongoDB wrapper** built for **FiveM** using Lua and TypeScript. It provides a simple and efficient way to interact with MongoDB databases inside your server scripts — supporting all essential operations such as `find`, `insert`, `update`, `delete`, and more.\n\n---\n\n## 🤔 For any issues or problems, we should leave.\n\n- [Issues Page](https://github.com/NoCapScripts-FiveM/fivemongo/issues)\n\n## 🚀 Features\n\n- ✅ Clean and readable Lua-based API  \n- ✅ Asynchronous operations with callback support  \n- ✅ Automatic `ObjectId` handling  \n- ✅ Compatible with ESX / QBCore  \n- ✅ Easily extendable for custom use cases  \n- ✅ Built with scalability in mind  \n\n---\n\n\n## 🍋 MongoDB Install\n\n-  [MongoDB](https://www.mongodb.com/docs/manual/administration/install-community/#std-label-install-mdb-community-edition)\n\n## 📦 Supported Operations\n\n- `Mongo:Find()`  \n- `Mongo:FindOne()`  \n- `Mongo:InsertOne()`  \n- `Mongo:InsertMany()`  \n- `Mongo:UpdateOne()`  \n- `Mongo:UpdateMany()`  \n- `Mongo:DeleteOne()`  \n- `Mongo:DeleteMany()`  \n- `Mongo:FindMany()`  \n- `Mongo:FindOneAndDelete()`  \n- `Mongo:Count()`  \n- `Mongo:Aggregate() `  *[TODO]*\n- `Mongo:FindSpec()` *(custom utility)*\n\n---\n\n## 📚 Example Usages\n\n\n\n```lua\nlocal Mongo\nRegisterCommand('getusers', function(source, args, rawCommand)\n    Mongo:FindMany({\n        collection = \"users\",\n        query = {}\n    }, function(err, users)\n        if not users or #users == 0 then\n            print(\"^1No users found.^7\")\n            return\n        end\n\n        for _, user in ipairs(users) do\n            print((\"User: %s | Last Login: %s\"):format(user.username, user.last_login or \"Never\"))\n        end\n    end)\nend, false)\n\n\nMongo:FindOne({\n    collection = \"developers\",\n    query = { steamhex = identifier }\n}, function(err, existingUser)\n    if (err) then\n        print(\"Error searching developer whitelist:\", err)\n        return cb(false)\n    end\n\n   \n\n    if (existingUser) then\n        -- User found in whitelist\n        print(\"User already in whitelist:\", json.encode(existingUser))\n        cb(true)  -- Already whitelisted, treat as success\n    elseif (not existingUser) then\n        -- User not found, insert new whitelist entry\n        Mongo:InsertOne({\n            collection = \"developers\",\n            document = {\n                steamhex = identifier,\n                addedAt = os.date(\"!%Y-%m-%dT%H:%M:%SZ\") -- ISO 8601 UTC timestamp\n            }\n        }, function(err, result)\n            if (err) then\n                print(\"Failed to add user to developer list:\", identifier, err)\n                cb(false)\n            else\n                print(\"User added to developer list:\", identifier)\n                cb(true)\n            end\n        end)\n    end\nend)\n\n\nMongo:InsertMany({\n    collection = \"users\",\n    documents = {\n        { username = \"user1\", email = \"user1@example.com\" },\n        { username = \"user2\", email = \"user2@example.com\" }\n    }\n}, function(err, result)\n    if err then\n        print(\"InsertMany Error:\", err)\n    else\n        print(\"Inserted documents:\", json.encode(result.insertedIds))\n    end\nend)\n\n\nMongo:UpdateOne({\n    collection = \"users\",\n    query = { username = \"jane_doe\" },\n    update = {\n        [\"$set\"] = { last_login = os.date(\"!%Y-%m-%dT%H:%M:%SZ\") } or last_login = os.date(\"!%Y-%m-%dT%H:%M:%SZ\") \n    }\n}, function(err, result)\n    if err then\n        print(\"UpdateOne Error:\", err)\n    else\n        print(\"Modified count:\", result.modifiedCount)\n    end\nend)\n\n\n\nMongo:UpdateMany({\n    collection = \"users\",\n    query = { active = false },\n    update = {\n        [\"$set\"] = { active = true }\n    }\n}, function(err, result)\n    if err then\n        print(\"UpdateMany Error:\", err)\n    else\n        print(\"Documents updated:\", result.modifiedCount)\n    end\nend)\n\n\n\n\nMongo:DeleteOne({\n    collection = \"users\",\n    query = { username = \"user_to_delete\" }\n}, function(err, result)\n    if err then\n        print(\"DeleteOne Error:\", err)\n    else\n        print(\"Deleted count:\", result.deletedCount)\n    end\nend)\n\n\n\n\nMongo:DeleteMany({\n    collection = \"users\",\n    query = { inactive = true }\n}, function(err, result)\n    if err then\n        print(\"DeleteMany Error:\", err)\n    else\n        print(\"Deleted documents:\", result.deletedCount)\n    end\nend)\n\n\nMongo:Count({\n    collection = \"users\",\n    query = { active = true }\n}, function(err, count)\n    if err then\n        print(\"CountDocuments Error:\", err)\n    else\n        print(\"Active users count:\", count)\n    end\nend)\n\n\nMongo:FindSpec({\n    collection = \"users\",\n    query = { age = { [\"$gt\"] = 18 } },\n    limit = 50\n}, function(err, data)\n    if err then\n        print(\"Error fetching users:\", err)\n        return\n    end\n\n    for _, user in ipairs(data) do\n        print((\"User: %s | Identifier: %s\"):format(user.username, user.identifier))\n    end\nend)\n\n\n\n-- TODO!\nMongo:Aggregate({\n    collection = \"users\",\n    pipeline = {\n        { [\"$match\"] = { active = true } },\n        { [\"$group\"] = {\n            _id = \"$country\",\n            count = { [\"$sum\"] = 1 }\n        }}\n    }\n}, function(err, results)\n    if err then\n        print(\"Aggregate Error:\", err)\n    else\n        for _, row in ipairs(results) do\n            print((\"Country: %s | Users: %d\"):format(row._id, row.count))\n        end\n    end\nend)\n\n\n\n```\n\n\n## ⚙️ Configuration\n\n\n```cfg\n\nset mongoCredentials \"mongodb+srv://acc:pw@cluster0.127c7e5.mongodb.net/db\"\nset mongoDatabase \"db\"\n\n```\n\n\nor \n\n\n\n```cfg\n\nset mongoCredentials \"mongodb://localhost:27017/db\"\nset mongoDatabase \"db\"\n\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnocapscripts-fivem%2Ffivemongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnocapscripts-fivem%2Ffivemongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnocapscripts-fivem%2Ffivemongo/lists"}