-1

my SimpleSchema.

Products.schema = new SimpleSchema({
 _id: {
  type: String,
  regEx: SimpleSchema.RegEx.Id
 },
 userId: {
  type:  String,
  regEx: SimpleSchema.RegEx.Id,
  denyUpdate: false
 },
 tags: {
  type: Object,
                optional: true,
                blackbox: true,
  label: 'Categoria del producto'
 }
 
});

Product array insert.

Let tags = ["7524", "5249", "7324"];

returns Error :tags product must be an object

with this type of object if it works:

var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
but I want to insert an object like this:

let tags = ["7524", "5249", "7324"];

I HOPE YOUR ANSWER AND GREETINGS.

Ankit
  • 1,118
  • 13
  • 21

1 Answers1

0

You need to specify the field with the object in this way. Then you can input the array.

Products.schema = new SimpleSchema({
    _id: {
        type: String,
        regEx: SimpleSchema.RegEx.Id
    },
    userId: {
        type:  String,
        regEx: SimpleSchema.RegEx.Id,
        denyUpdate: false
    },
    tags: {
      type: Array,
      optional: true,
      label: 'Categoria del producto'

   },
   "tags.$": {
      type: Object, 
   }

});
Ankit
  • 1,118
  • 13
  • 21
  • thanks for answering .but I get this error. Invalid definition for tags.$ field. I am working with the 1.4.0.1 version of Meteor. – Black Hawk Sep 11 '16 at 19:34
  • Sorry. My mistake. I wrote the type wrong. I have edited the answer. This should work. – Ankit Sep 13 '16 at 17:33
  • thanks for your help to solve .the problem comes was there , http://stackoverflow.com/questions/38003774/meteor-collection2-array-with-strings-and-object?rq=1 – Black Hawk Sep 13 '16 at 20:52