3

I am using Meteor with a pre-existing database which uses custom objects in the _id field. I have defined the structure with Meteor like this:

_id: {
    type: Object,
    label: "ID"
},

"_id.templateId" : {
    type: String,
    label: "Template ID",
    optional: false
},

"_id.locale": {
    type: String,
    optional: false
},

However, when I try to use the collection, I get an error stating that "Meteor does not currently support objects other than ObjectID as ids."

Is there a workaround which would allow me to use this collection in Meteor without having to change the existing database?

Kyll
  • 7,036
  • 7
  • 41
  • 64
Marco Tribuzio
  • 103
  • 1
  • 1
  • 6
  • 6
    The error says "Error: Meteor does not currently support objects other than ObjectID as ids", that should tell you everything you need to know. – user3374348 Aug 31 '15 at 08:49
  • As for the issue I think it will be extremely hard to circumvent this measure of Meteor, which relies heavily on the `_id` being a `String` or an `ObjectId`. You may instead want to migrate your entire database to use `yourProductId` to place the information you want, and then if needed index the new Mongo database with `_ensureIndex`. – Kyll Sep 01 '15 at 09:18
  • @Marco Did you find the solution? I also stuck in the same issue. – Harish Kommuri Apr 13 '17 at 10:01
  • @HarishKommuri sorry but at the moment i didn't find a solution :( – Marco Tribuzio Apr 22 '17 at 09:45

1 Answers1

0

You are trying to use an object literal as an id composition, but Meteor only supports String and ObjecID but String is preferable because almost every package that rely on id information assume strings.

Also, the built in accounts system cannot work with anything other than simple string id's.

Serkan Durusoy
  • 5,447
  • 2
  • 20
  • 39