Using mongoose to query a mongo DB that was from a meteor DB

I’m trying to run this query using mongoose against a db created by a meteor app and simple schema…

await Organizations.find({_id: {$in: orgIds}})

Getting this error

CastError: Cast to ObjectId failed for value "PS63k9zXwxtx3Lz8y" at path "_id" for model "Organizations"

UPDATE:

It was just a matter of adding an _id as a string to the mongoose schema

e.g.

const schema = new Mongo.Schema({
  _id: String,
  email: {
    type: String
  },
1 Like

Hi, does it still work ok for you? What happens when you create new data using mongoose, do they work with Meteor (basically the other way around from what you posted originally)?

I was wondering if it’s possible to convert the existing string ids to ObjectId but they don’t seem to have the right structure, so we probably need to fallback to String _id for collections that already exists in Meteor.