M
Mastra2w ago
Sergio

MongoDb storage error in beta release

Hello everyone! I have a doubt when using Mondogb storage in beta version. When creating the storage using MongoDBStore:
import { MongoDBStore, MongoDBVector } from "@mastra/mongodb";
import { env } from "../../env";


export const mongodbVector = new MongoDBVector({
id: 'mongodb-vector',
uri: env.MONGODB_URI,
dbName: env.MONGODB_DATABASE,
});

export const mongodbStorage = new MongoDBStore({
id: 'mongodb-storage',
url: env.MONGODB_URI,
dbName: env.MONGODB_DATABASE,
});
import { MongoDBStore, MongoDBVector } from "@mastra/mongodb";
import { env } from "../../env";


export const mongodbVector = new MongoDBVector({
id: 'mongodb-vector',
uri: env.MONGODB_URI,
dbName: env.MONGODB_DATABASE,
});

export const mongodbStorage = new MongoDBStore({
id: 'mongodb-storage',
url: env.MONGODB_URI,
dbName: env.MONGODB_DATABASE,
});
it throws an error when I initialize Mastra
export const mastraMongo = new Mastra({
vectors: {
mongodbVector,
},
storage: mongodbStorage
});
export const mastraMongo = new Mastra({
vectors: {
mongodbVector,
},
storage: mongodbStorage
});
error says
Type 'MongoDBStore' is not assignable to type 'MastraStorage'.
The types returned by 'saveMessages(...)' are incompatible between these types.
Type 'Promise<{ messages: MastraDBMessage[]; }>' is not assignable to type 'Promise<MastraMessageV1[]>'.
Type '{ messages: MastraDBMessage[]; }' is missing the following properties from type 'MastraMessageV1[]': length, pop, push, concat, and 29 more.
Type 'MongoDBStore' is not assignable to type 'MastraStorage'.
The types returned by 'saveMessages(...)' are incompatible between these types.
Type 'Promise<{ messages: MastraDBMessage[]; }>' is not assignable to type 'Promise<MastraMessageV1[]>'.
Type '{ messages: MastraDBMessage[]; }' is missing the following properties from type 'MastraMessageV1[]': length, pop, push, concat, and 29 more.
3 Replies
Mastra Triager
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10667 🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly. 🙏 Thank you for helping us improve Mastra!
Abhi Aiyer
Abhi Aiyer2w ago
Are you on all beta versions ? If you’re using the beta mongodb version the core version should also be in 1.0.0 the type error I’m seeing seems to come from a mismatch since we change message type in v1 Just try and reproduced this myself, it definitely is a version mismatch issue. Please make sure youre on all latest beta versions of any mastra package!
Sergio
SergioOP2w ago
thanks mate! confirmed it was solved

Did you find this page helpful?