simpl-schema import fails while assigning to an object variable

49 Views Asked by At

I have two files with schemas, that i want to assign to a variable in a third schema file as depicted below

abcCollection.js

import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';

const abcCollection = new Mongo.Collection('abc');

const abcSchema = new SimpleSchema({
  ...
});

abcCollection.attachSchema(abcSchema);

export { abcCollection, abcSchema };

xyzCollection.js

import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';

const xyzCollection = new Mongo.Collection('xyz');

const xyzSchema = new SimpleSchema({
  ...
});

xyzCollection.attachSchema(xyzSchema);

export { xyzCollection, xyzSchema };

I am importing these files in another third file and trying to use it as either or value for an object variable as shown below

pqrCollection.js

import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import abcSchema from '/imports/abcCollection';
import xyzSchema from '/imports/xyzCollection';

const pqrCollection = new Mongo.Collection('pqr');

const pqrSchema = new SimpleSchema({


  plan: {
    type: SimpleSchema.oneOf(String, SimpleSchema.RegEx.Url),
    optional: true,
  },

  abc_xyz_pqr: {
    type: Object,
    optional: true,
  },
  'abc_xyz_pqr.schema': {
    type: SimpleSchema.oneOf(abcSchema, xyzSchema),
  },

});

pqrCollection.attachSchema(pqrSchema);

export { pqrCollection };

However i am getting the following error:

Error: Invalid definition for abc_xyz_pqr.schema field: "type" option is required

here is the versions of my simpl-schema and aldeed collections "simpl-schema": "^1.12.0", aldeed:collection2 3.4.1

not sure why it is not able to import at assign those schemas

0

There are 0 best solutions below