I recently was working on something for my portfolio which would use the MongoDB Data API to allow roblox to write and read data to the database, I’ve decided to release it here if anyone would like to use it.
Model:
Since i’m lazy to write a documentation, I’ll leave a sample usage down below:
local MongoStore = require(game.ServerStorage.Source.MongoStore)
local Auth = MongoStore.MongoRB.Authenticate(
"YourURLEndpoint",
"YourAPIKey"
)
local Connection = MongoStore.MongoRB.Connect(Auth)
Connection:SetCluster("CluserName")
Connection:SetDatabase("DatbaseName")
Connection:SetCollection("CollectionName")
local MongoStore = MongoStore:New(Connection)
print(MongoStore:SetAsync("PlayerIdentifier", {koolaid = {"woah", "woah2"}})) --// Will either print true or false, whether the request succeeded or not.
print(MongoStore:GetAsync("PlayerIdentifier")) --// Will either print the data or nil, meaning there is no data for that key
print(MongoStore:HasData("PlayerIdentifier")) --// Self explanitory, true or false
Thank you for reading!