mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-20 19:24:29 +00:00
27 lines
645 B
TypeScript
27 lines
645 B
TypeScript
import { ERROR_ENUM } from '@fastgpt/global/common/error/errorCode';
|
|
import { MongoDatasetCollection } from './collection/schema';
|
|
import { DatasetSchemaType } from '@fastgpt/global/core/dataset/type';
|
|
|
|
export async function authCollection({
|
|
collectionId,
|
|
userId
|
|
}: {
|
|
collectionId: string;
|
|
userId: string;
|
|
}) {
|
|
const collection = await MongoDatasetCollection.findOne({
|
|
_id: collectionId,
|
|
userId
|
|
})
|
|
.populate('datasetId')
|
|
.lean();
|
|
|
|
if (collection) {
|
|
return {
|
|
...collection,
|
|
dataset: collection.datasetId as unknown as DatasetSchemaType
|
|
};
|
|
}
|
|
return Promise.reject(ERROR_ENUM.unAuthDataset);
|
|
}
|