Skip to content

Commit

Permalink
fix: applied $filter in object
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Sep 13, 2023
1 parent f49516a commit 1d05b5c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class CoCreateFileSystem {
let org = await crud.send({
method: 'read.object',
array: 'organizations',
filter: {
query: [
{ key: "host", value: [hostname], operator: "$in" }
]
object: {
$filter: {
query: [
{ key: "host", value: [hostname], operator: "$in" }
]
}
},
organization_id: process.env.organization_id
})
Expand Down Expand Up @@ -99,11 +101,14 @@ class CoCreateFileSystem {
let data = {
method: 'read.object',
array: 'files',
filter: {
query: [
{ key: "host", value: [hostname, '*'], operator: "$in" },
{ key: "path", value: pathname, operator: "$eq" }
]
object: {
$filter: {
query: [
{ key: "host", value: [hostname, '*'], operator: "$in" },
{ key: "path", value: pathname, operator: "$eq" }
],
limit: 1
}
},
organization_id
}
Expand Down Expand Up @@ -175,18 +180,17 @@ class CoCreateFileSystem {
}

async function getDefaultFile(fileName) {
data.filter.query[1].value = fileName
data.object.$filter.query[1].value = fileName
let defaultFile
if (fileName !== '/hostNotFound.html')
defaultFile = await crud.send(data);

if (defaultFile && defaultFile.object && defaultFile.object[0] && defaultFile.object[0].src) {
return defaultFile.object[0]
} else {
data.filter.query[0].value = ['*']
data.object.$filter.query[0].value = ['*']
data.organization_id = process.env.organization_id


defaultFile = await crud.send(data)

if (fileName !== '/hostNotFound.html') {
Expand Down

0 comments on commit 1d05b5c

Please sign in to comment.