I NO LONGER MAINTAIN THIS. A V2 WILL BE RELEASED WITHIN THIS YEAR.
Hello all! With the release of MongoDB’s beta Data API, I’ve decided to make an API wrapper for it. Please note a small amount of experience with MongoDB is required to use this.
The wrapper is simple to use & open sourced to all.
Firstly, lets move onto a simple tutorial:
The first course of action is to prepare your database. Once you’ve provisioned your database, head on over to Data API
Next, lets select our data sources that we want to be accessible. After that, create an API key and DO NOT SHARE IT WITH ANYONE ELSE!. Copy your key and keep it somewhere safe.
Make sure you also copy the URL endpoint, as we will need it.
Okay! You’ve successfully prepared all your materials. Now lets head onto studio! Let’s begin by requiring the module locally or from the web.
local APIModule = require(8772252865)
After that, let’s set our API key and endpoint we got from earlier.
APIModule:New("<API KEY>","<API ENDPOINT>")
Congratulations, you are now ready to begin using the module to its full extent. Let’s insert a test document.
APIModule:InsertOne({name = "Test"},"<DATA SOURCE>","<DATABASE","<COLLECTION>")
should be the name of one of the data sources you selected in Data API. should be the database inside said data source. should be the collection inside that database. InsertOne will return the inserted object IDs after they have been inserted. Congratulations! You have created your first document with rbx-to-mongo!
Okay, lets now find that document.
APIModule:FindOne({name = "Test"},"<DATA SOURCE>","<DATABASE","<COLLECTION>")
Awesome, the API will return the document and all of its elements in a LUA table for you. Now let’s delete the document.
APIModule:DeleteOne({name = "Test"},"<DATA SOURCE>","<DATABASE","<COLLECTION>")
Nice, you’ve learned the basics of the wrapper.
Sometimes adding the Data Source, Database, and Collection in every request can make your code look lengthy. You can use this function to make them automatically passed into the request without having to specify them:
APIModule:Change("<STATIC SOURCE>","<STATIC DATABASE>","<STATIC COLLECTION>")
However, you may be constantly changing collections, sources, or databases. Don’t worry as passed in collections/databases/sources are prioritized over the static one.
Source:
MongoDB Data API Documentation (All functions from here are on the wrapper so read it!):
GitHub (Wiki is being made):
Thanks for reading!
MemAddress