in src/models/server/question.collection.ts, we can add a delay to ensure attributes are fully propagated before indexing;
await Promise.all([
databases.createStringAttribute(db, questionCollection, "title", 100, true),
databases.createStringAttribute(db, questionCollection, "content", 10000, true),
databases.createStringAttribute(db, questionCollection, "authorId", 50, true),
databases.createStringAttribute(db, questionCollection, "tags", 50, true, undefined, true),
databases.createStringAttribute(db, questionCollection, "attachmentId", 50, false),
]);
console.log("Attributes created successfully");
// Adding a delay to ensure attributes are fully available before indexing
await new Promise(resolve => setTimeout(resolve, 2000));
await Promise.all([
databases.createIndex(db, questionCollection, "title", IndexType.Fulltext, ["title"], ["asc"]),
databases.createIndex(db, questionCollection, "content", IndexType.Fulltext, ["content"], ["asc"]),
]);
console.log("Indexes created successfully");
in
src/models/server/question.collection.ts, we can add a delay to ensure attributes are fully propagated before indexing;