Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
920 stars 162 forks source link

[Object, Object] JSON Array does support or not? #689

Closed varunajmera0 closed 7 years ago

varunajmera0 commented 7 years ago

image

how to save in aldeed: Simple-collection? code:

var data= [];
  for(var i=0;i<iptCount;i++){
 var  name = upload_file.files[i].name;
      var   title = cap[i].value;
  data.push({name,title});
}
Photo.insert({
            ownerId: Meteor.userId(),
            photo_Info:data
        });

Schema:
var Schema= {};
Photo = new Mongo.Collection('photo');
Schemas.Photo = new SimpleSchema({
    ownerId:{
        type:String
    },
    photo_Info:{
        type:[Object]
    } ,
    date:{
        type: Date,
        autoValue: function() {
           return new Date()
       }
    }
});

Photo.attachSchema(Schemas.Photo);
aldeed commented 7 years ago

You need to define all props the object will have:

photo_Info: {
  type: Array
},
'photo_Info.$': {
  type: Object
},
'photo_Info.$.name': {
  type: String
},
'photo_Info.$.title': {
  type: String
},
varunajmera0 commented 7 years ago

thanks man @aldeed