Compare commits
2 Commits
main
...
feature/fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
be4e83588b | ||
![]() |
06304f1aee |
@ -52,8 +52,7 @@ return {
|
||||
self._checkInstallation = function()
|
||||
if not self then error("Please Setup MarcSync before using MarcSync.") end
|
||||
if not self._accessToken then error("[MarcSync] Please set a Token before using MarcSync.") end
|
||||
--print(HttpService.HttpEnabled)
|
||||
--if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end
|
||||
if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end
|
||||
end
|
||||
|
||||
self = setmetatable(self, {
|
||||
@ -62,4 +61,4 @@ return {
|
||||
|
||||
return self
|
||||
end
|
||||
}
|
||||
}
|
@ -2,7 +2,8 @@ local Utils = require(script.Parent.Parent.Utils)
|
||||
local Entry = require(script.Parent.Entry)
|
||||
|
||||
local types = {
|
||||
EntryData = require(script.Parent.Parent.Types.EntryData).getType()
|
||||
EntryData = require(script.Parent.Parent.Types.EntryData).getType(),
|
||||
FilterData = require(script.Parent.Parent.Types.FilterData).getType()
|
||||
}
|
||||
|
||||
local Collection = {}
|
||||
@ -21,18 +22,24 @@ Collection.createEntry = function(self:typeof(Collection), data:typeof(types.Ent
|
||||
return result
|
||||
end
|
||||
|
||||
Collection.updateEntries = function(self:typeof(Collection), filters:typeof(types.EntryData), data:typeof(types.EntryData)):number
|
||||
Collection.updateEntries = function(self:typeof(Collection), filters:typeof(types.FilterData), data:typeof(types.EntryData)):number
|
||||
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
|
||||
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken);
|
||||
if not filters then filters = {} end
|
||||
if not filters._startsWith then filters._startsWith = {} end
|
||||
if not filters._ignoreCases then filters._ignoreCases = {} end
|
||||
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v1/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken);
|
||||
if not result["success"] then error(result["errorMessage"]) end
|
||||
|
||||
return result["modifiedEntries"]
|
||||
end
|
||||
|
||||
Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):{[number]:typeof(Entry.new())}
|
||||
Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.FilterData), limit: number):{[number]:typeof(Entry.new())}
|
||||
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
|
||||
if not filters then filters = {} end
|
||||
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName.."?isQuery=true", {["filters"]=filters}, self._accessToken);
|
||||
if not filters._startsWith then filters._startsWith = {} end
|
||||
if not filters._ignoreCases then filters._ignoreCases = {} end
|
||||
if not limit then limit = 0 end
|
||||
local result = Utils.makeHTTPRequest("entry", "PATCH", "https://api.marcsync.dev/v1/entries/"..self._collectionName.."?methodOverwrite=GET", {["filters"]=filters, ["limit"] = limit}, self._accessToken);
|
||||
if result["success"] and result["entries"] then
|
||||
local _result = {}
|
||||
for index,entry in pairs(result["entries"]) do
|
||||
@ -46,9 +53,12 @@ Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.E
|
||||
return result
|
||||
end
|
||||
|
||||
Collection.deleteEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):number
|
||||
Collection.deleteEntries = function(self:typeof(Collection), filters:typeof(types.FilterData)):number
|
||||
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
|
||||
local result = Utils.makeHTTPRequest("DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken);
|
||||
if not filters then filters = {} end
|
||||
if not filters._startsWith then filters._startsWith = {} end
|
||||
if not filters._ignoreCases then filters._ignoreCases = {} end
|
||||
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v1/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken);
|
||||
if not result["success"] then error(result["errorMessage"]) end
|
||||
|
||||
return result["deletedEntries"]
|
||||
|
@ -16,7 +16,7 @@ Entry.getValues = function(self:typeof(Entry)):typeof(types.EntryData)
|
||||
end
|
||||
|
||||
Entry.updateValues = function(self:typeof(Entry), data:typeof(types.EntryData)):number
|
||||
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken);
|
||||
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v1/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken);
|
||||
|
||||
if result["success"] and result["modifiedEntries"] and result["modifiedEntries"] > 0 then
|
||||
for i,v in pairs(data) do
|
||||
@ -31,7 +31,7 @@ end
|
||||
|
||||
Entry.delete = function(self:typeof(Entry))
|
||||
if typeof(self) ~= "table" then error("Please use : instead of .") end
|
||||
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
|
||||
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v1/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
|
||||
|
||||
if not result["success"] then error(result["errorMessage"]) end
|
||||
self = nil
|
||||
|
11
src/MarcSync/Types/FilterData.lua
Normal file
11
src/MarcSync/Types/FilterData.lua
Normal file
@ -0,0 +1,11 @@
|
||||
type FilterData = {
|
||||
["_startsWith"]: {string},
|
||||
["_ignoreCases"]: {string},
|
||||
[string]: any
|
||||
}
|
||||
|
||||
return {
|
||||
getType = function(): FilterData
|
||||
return {}
|
||||
end,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user