Skip to content

Commit bbabb51

Browse files
committed
fix bug
1 parent 7bef168 commit bbabb51

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

Minio-SQL-connector/api/controllers/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
getValues: async (req, res) => {
5555
logger.info("values")
5656
try {
57-
res.send(await service.getValues())
57+
res.send(await service.getValues(req.body.prefix, req.body.bucketName, req.headers.visibility))
5858
}
5959
catch (error) {
6060
logger.error(error)
@@ -76,7 +76,7 @@ module.exports = {
7676
getKeys: async (req, res) => {
7777
logger.info("keys")
7878
try {
79-
res.send(await service.getKeys())
79+
res.send(await service.getKeys(req.body.prefix, req.body.bucketName, req.headers.visibility))
8080
}
8181
catch (error) {
8282
logger.error(error)

Minio-SQL-connector/api/services/service.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ async function sync() {
9090

9191
//const existingEntries = await Entries.find({ key: { $in: Object.keys(minioWriter.entries) } }); //TODO now this line is useless
9292

93-
//let entries = Object.entries(minioWriter.entries).map(([key, value]) => ({ [key]: value }));
94-
let entries = []
93+
let entries = Object.entries(minioWriter.entries).map(([key, value]) => ({ [key]: value }));
94+
let entriesInDB = []
9595
for (let key in minioWriter.entries)
9696
for (let value in minioWriter.entries[key])
97-
entries.push({
97+
entriesInDB.push({
9898
key,
9999
value,
100100
visibility: minioWriter.entries[key][value]
101101
})
102102
try {
103-
if (entries.length > 0) await Entries.insertMany(entries);
103+
if (entriesInDB.length > 0) await Entries.insertMany(entriesInDB);
104104
} catch (error) {
105105
if (!error?.errorResponse?.message?.includes("Document can't have")) {
106106
log(error);
@@ -344,12 +344,26 @@ function objectFilter(obj, prefix, bucket, visibility) {
344344

345345
module.exports = {
346346

347-
async getKeys() {
348-
return await Key.find()
347+
async getKeys(prefix, bucketName, visibility) {
348+
if (visibility == "private")
349+
visibility = prefix.split("/")[0]
350+
else if (visibility == "shared")
351+
visibility = bucketName.toUpperCase() + " SHARED Data"
352+
else
353+
visibility = "public-data"
354+
console.debug(visibility)
355+
return await Key.find({ visibility }, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
349356
},
350357

351-
async getValues() {
352-
return await Value.find()
358+
async getValues(prefix, bucketName, visibility) {
359+
if (visibility == "private")
360+
visibility = prefix.split("/")[0]
361+
else if (visibility == "shared")
362+
visibility = bucketName.toUpperCase() + " SHARED Data"
363+
else
364+
visibility = "public-data"
365+
console.debug(visibility)
366+
return await Value.find({ visibility }, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
353367
},
354368

355369
async getEntries(prefix, bucketName, visibility) {
@@ -361,7 +375,7 @@ module.exports = {
361375
else
362376
visibility = "public-data"
363377
console.debug(visibility)
364-
return await Entries.find({ visibility })
378+
return await Entries.find({ visibility }, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
365379
},
366380

367381

0 commit comments

Comments
 (0)