这是我收到的错误:"MissingSchemaError:尚未为模型"Business"注册架构."
我在用AstraDB矢量数据库.我做了一个函数来初始化Mongoose模型:
export const initMongooseBusinessModel = async () => {
const Business = mongoose.model(
"Business",
new mongoose.Schema(
{
business_id: String,
$vector: {
type: [Number],
validate: (vector) => vector && vector.length === 1536,
},
},
{
collectionOptions: {
vector: {
size: 1536,
function: "cosine",
},
},
},
),
);
await Business.init();
console.log("complete")
};
我正try 在另一个文件的函数中使用该模型:
import mongoose from "mongoose"
export const addToAstraDB = async (url) => {
try {
const Business = mongoose.model("Business")
const businessURL = url
// Rest of the code goes here...
我收到了这个错误: