|
|
|
@@ -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"]
|
|
|
|
|