meteor-astronomy icon indicating copy to clipboard operation
meteor-astronomy copied to clipboard

advice on indexes on 'type'

Open meecect opened this issue 4 years ago • 2 comments

I have something like:

export const Entity = Class.create({
  name: 'Entity',
  collection: Entities,
  typeField: 'type',
  fields: {
    uuid: {
      type: String,
      optional: true,
    },
    published: {
      type: Boolean,
      default: true,
    },

and then numerous subclasses of that.

I was thinking of adding an index on type so I did like this:

export const Entity = Class.create({
  name: 'Entity',
  collection: Entities,
  typeField: 'type',
  fields: {
    type: {
      type: String,
      index: "String"
    },
    uuid: {
      type: String,
      optional: true,
    },

Does that sound reasonable? Is there any issue defining the field (and the index) like that even though I already specified the 'typeField' parameter?

Thanks

meecect avatar Apr 23 '20 19:04 meecect

@meecect you don't have to do that. Astronomy is already creating index for the type field for you https://github.com/jagi/meteor-astronomy/blob/v2/lib/modules/storage/hooks/apply_definition.js#L100

lukejagodzinski avatar Apr 23 '20 22:04 lukejagodzinski

thank you, I was kinda assuming that it would, but thought I'd ask anyway.

meecect avatar Apr 25 '20 06:04 meecect