I would do it like this:
local DataStoreService = game:GetService("DataStoreService")
local rSQL = require(game.ReplicatedStorage.Packages.rSQL)
local config = {
allowCreate = true,
allowInsert = true,
allowSelect = true,
}
local datastore = DataStoreService:GetDataStore("SearchExampleDatabase" .. os.time())
local connection = rSQL:connect(datastore, config):expect()
local function searchWithSubstring(connection, tableName, searchString)
local queryResult = connection:query(string.format("SELECT * FROM %s", tableName)):expect()
print(queryResult)
-- ur logic here but data looks like this:
-- ▼ {
-- [1] = ▼ {
-- ["author_id"] = "0",
-- ["contents"] = "GENERIC_JSON_DATA_HERE",
-- ["id"] = "0",
-- ["name"] = "Bunker"
-- },
-- [2] = ▼ {
-- ["author_id"] = "0",
-- ["contents"] = "GENERIC_JSON_DATA_HERE",
-- ["id"] = "1",
-- ["name"] = "House"
-- },
-- [3] = ▼ {
-- ["author_id"] = "2",
-- ["contents"] = "GENERIC_JSON_DATA_HERE",
-- ["id"] = "4",
-- ["name"] = "Rustacean"
-- }
--}
end
connection:query("CREATE TABLE Locations (name, id, author_id, contents)"):expect()
connection:query("INSERT INTO Locations (name, id, author_id, contents) VALUES ('Bunker', 0, 0, 'GENERIC_JSON_DATA_HERE')"):expect()
connection:query("INSERT INTO Locations (name, id, author_id, contents) VALUES ('House', 1, 0, 'GENERIC_JSON_DATA_HERE')"):expect()
connection:query("INSERT INTO Locations (name, id, author_id, contents) VALUES ('Rustacean', 4, 2, 'GENERIC_JSON_DATA_HERE')"):expect()
local results = searchWithSubstring(connection, "Locations", "U")
print("Search Results:")
for _, row in ipairs(results) do
print(row)
end
By the way it seems you made me find a bug in the YACC.luau and ACT Tree which prevents rows from having spaces, will release a patch ASAP.