Rongo
MongoDB API Wrapper for Roblox
v1.0.0
Read our article on the MongoDB Developer Hub
Want an alternative to DataStore? Check out MongoStore
Download on Roblox
Download on Github
Install with Wally
View Source
What is Rongo?
Rongo is an open-source API wrapper for MongoDB, which is a document oriented database program.
Rongo gives developers an easy to use, object oriented & type safe module which serves as an interface to MongoDBâs Data API for developers to use as an alternative to DataStoreService or a variety of other uses!
Rongo is still in early development & I plan to extend it as more MongoDB APIâs are released & to add additional features to it.
Rongo is licensed under the MIT License
How do I install Rongo?
It is pretty simple to install Rongo, all you need to do is either get the model on Roblox or download the file on Github!
Once youâve gotten either of those, insert it into ServerScriptService
& then youâre ready to start using it!
You can also install Rongo via Wally by adding rongo = "starnamics/rongo@1.1.2"
into your wally.toml
file (make sure to get the latest version on Wally)
Scroll down for some usage examples & documentation
Examples
Setting up the Data API
Follow the steps below to get MongoDBâs Data API Setup
1 - Click on the âData APIâ page in MongoDB
2 - Enable the Data API
(make sure to select the sources)
3 - Copy your API ID & store it somewhere safe
(only copy this, donât copy the entire URL)
4 - Click on the âCreate API Keyâ button
5 - Enter a name then press the generate button
Copy your API key & store it somewhere safe
Once youâve done all these steps you should be good to go and youâre ready to setup Rongo in your game!
Using Rongo in your game
After youâve set up the Data API & installed Rongo in your game, you can start using it. Below will teach you the basics of getting it set up!
1 - Create a script in ServerScriptService
2 - Paste the code below into the new script
local ServerScriptService = game:GetService("ServerScriptService")
local Rongo = require(ServerScriptService.Rongo) --// Replace this with the location of the Rongo module
local Client = Rongo.new(YOUR_API_ID, YOUR_API_KEY) --// Replace these with the ID and key you stored earlier!
local Cluster = Client:GetCluster("Cluster Name") --// Replace this with the name of your cluster (usually "Cluster0")
local Database = Cluster:GetDatabase("example") --// Replace this with the name of your database!
local Collection = Database:GetCollection("example") --// Replace this with the name of your collection inside your database
Above is some code to get you started, make sure to fill in the arguments!
3 - Inserting a document in your collection
Below the code above, you can paste this below to learn how to insert a document inside of your collection!
local MyDocument = {
["name"] = "This is my first document!",
["description"] = "I inserted this using Rongo!"
}
Collection:InsertOne(MyDocument) --// This will insert the document you typed out above!
local NewDocument = Collection:FindOne({["name"] = MyDocument.name}) --// This will find the document you just created!
print("My Document:",NewDocument) --// This will print out your document into the output!
Thatâs all for the basic setup of Rongo! If youâd like to learn more, read our documentation!
Documentation
Classes
Functions
Module
function Rongo.new(AppId: string,AppKey: string) -> Client
AppId: The ID inside your Data API URL
AppiKey: The API Key which you generated in MongoDB
Client
function Client:GetCluster(Name: string) -> Cluster
Name: The name of your Cluster, the default one is usually 'Cluster0'
Cluster
function Cluster:GetDatabase(Name: string) -> Database
Name: The name of your database
Database
function Database:GetCollection(Name: string) -> Collection
Name: The name of your collection inside the database
Collection
function Collection:FindOne(Filter: {[string]: string | {[string]: string}}?): {[string]: any?}
Filter: The filter for finding the document, refer to MongoDB documentation for examples
function Collection:FindMany(Filter: {[string]: string | {[string]: string}}?,Limit: number?,Sort: {any?}?,Skip: number?): {{[string]: any?}}
Filter: The filter for finding the documents, refer to MongoDB documentation for examples
Limit: The maximum amount of documents that will be returned (Default: 1000)
Sort: The dictionary used to sort the documents, refer to MongoDB documentation for examples (Default: {})
Skip: The amount of documents to skip (Default: 0)
function Collection:InsertOne(Document: {[string]: any?}): string?
Document: The document you'd like to insert into the collection
function Collection:InsertMany(Documents: {{[string]: any?}}): string?
Documents: The documents you'd like to insert into the collection
function Collection:UpdateOne(Filter: string,Update: {[string]: any?},Upsert: boolean?): {["matchedCount"]: number,["modifiedCount"]: number,["upsertedId"]: string?}?
Filter: The filter for updating the document, refer to MongoDB documentation for examples
Update: The dictionary for the updated document
Upsert: Whether or not the document should be inserted if it does not exist (Default: false)
function Collection:UpdateMany(Filter: string,Update: {[string]: any?},Upsert: boolean?): {["matchedCount"]: number,["modifiedCount"]: number,["upsertedId"]: string?}?
Filter: The filter for updating the documents, refer to MongoDB documentation for examples
Update: The dictionary for the updated documents
Upsert: Whether or not the documents should be inserted if it does not exist (Default: false)
function Collection:ReplaceOne(Filter: string,Replacement: {[string]: any?},Upsert: boolean?}) : {["matchedCount"]: number,["modifiedCount"]: number,["upsertedId"]: string?}?
Filter: The filter for replacing the document, refer to MongoDB documentation for examples
Replacement: The document to replace the current one with
Upsert: Whether or not the documents should be inserted if it does not exist (Default: false)
function Collection:DeleteOne(Filter: {[string]: string | {[string]: string}}?): {[string]: any?}
Filter: The filter for deleting the document, refer to MongoDB documentation for examples
function Collection:DeleteMany(Filter: {[string]: string | {[string]: string}}?): {[string]: any?}
Filter: The filter for deleting the documents, refer to MongoDB documentation for examples
Resources
These are some open-source resources which make use of Rongo!
Credits
Rongo was developed by @Starnamics & was made possible by MongoDB
Feel free to use Rongo in whatever way you want as long as it follows the license terms
Thank you!