mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 02:50:10 +01:00
Return threads for API workspace calls (#1978)
* Return threads for API workspace calls * remove import
This commit is contained in:
parent
013c0b9575
commit
ae58a2cb0d
@ -103,7 +103,8 @@ function apiWorkspaceEndpoints(app) {
|
||||
"openAiTemp": null,
|
||||
"lastUpdatedAt": "2023-08-17 00:45:03",
|
||||
"openAiHistory": 20,
|
||||
"openAiPrompt": null
|
||||
"openAiPrompt": null,
|
||||
"threads": []
|
||||
}
|
||||
],
|
||||
}
|
||||
@ -118,7 +119,17 @@ function apiWorkspaceEndpoints(app) {
|
||||
}
|
||||
*/
|
||||
try {
|
||||
const workspaces = await Workspace.where();
|
||||
const workspaces = await Workspace._findMany({
|
||||
where: {},
|
||||
include: {
|
||||
threads: {
|
||||
select: {
|
||||
user_id: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
response.status(200).json({ workspaces });
|
||||
} catch (e) {
|
||||
console.error(e.message, e);
|
||||
@ -152,7 +163,8 @@ function apiWorkspaceEndpoints(app) {
|
||||
"lastUpdatedAt": "2023-08-17 00:45:03",
|
||||
"openAiHistory": 20,
|
||||
"openAiPrompt": null,
|
||||
"documents": []
|
||||
"documents": [],
|
||||
"threads": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +179,21 @@ function apiWorkspaceEndpoints(app) {
|
||||
*/
|
||||
try {
|
||||
const { slug } = request.params;
|
||||
const workspace = await Workspace.get({ slug });
|
||||
const workspace = await Workspace._findMany({
|
||||
where: {
|
||||
slug: String(slug),
|
||||
},
|
||||
include: {
|
||||
documents: true,
|
||||
threads: {
|
||||
select: {
|
||||
user_id: true,
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
response.status(200).json({ workspace });
|
||||
} catch (e) {
|
||||
console.error(e.message, e);
|
||||
|
@ -302,6 +302,37 @@ const Workspace = {
|
||||
);
|
||||
return;
|
||||
},
|
||||
|
||||
// Direct DB queries for API use only.
|
||||
/**
|
||||
* Generic prisma FindMany query for workspaces collections
|
||||
* @param {import("../node_modules/.prisma/client/index.d.ts").Prisma.TypeMap['model']['workspaces']['operations']['findMany']['args']} prismaQuery
|
||||
* @returns
|
||||
*/
|
||||
_findMany: async function (prismaQuery = {}) {
|
||||
try {
|
||||
const results = await prisma.workspaces.findMany(prismaQuery);
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generic prisma query for .get of workspaces collections
|
||||
* @param {import("../node_modules/.prisma/client/index.d.ts").Prisma.TypeMap['model']['workspaces']['operations']['findFirst']['args']} prismaQuery
|
||||
* @returns
|
||||
*/
|
||||
_findFirst: async function (prismaQuery = {}) {
|
||||
try {
|
||||
const results = await prisma.workspaces.findFirst(prismaQuery);
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { Workspace };
|
||||
|
@ -1476,7 +1476,8 @@
|
||||
"openAiTemp": null,
|
||||
"lastUpdatedAt": "2023-08-17 00:45:03",
|
||||
"openAiHistory": 20,
|
||||
"openAiPrompt": null
|
||||
"openAiPrompt": null,
|
||||
"threads": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1539,7 +1540,8 @@
|
||||
"lastUpdatedAt": "2023-08-17 00:45:03",
|
||||
"openAiHistory": 20,
|
||||
"openAiPrompt": null,
|
||||
"documents": []
|
||||
"documents": [],
|
||||
"threads": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user