12

I have a schema with a field type: Object . But whenever i do an insert, that object is empty.

Here is my schema

Contacts.attachSchema(new SimpleSchema({
    firstName: {
        type: String,

    },
    lastName: {
        type: String,
        optional: true
    },
    twitterFriend: { // this field
        type: Object,
        optional: true
    }
}));

Even if do Contacts.insert({firstName: 'Mustafa', twitterFriend: {test: 'this should be stored'}}) . It does not work.

Mustafa
  • 1,738
  • 2
  • 24
  • 34

1 Answers1

21

For an object of arbitrary sub-schema you set blackbox: true

Contacts.attachSchema(new SimpleSchema({
    firstName: {
        type: String,

    },
    lastName: {
        type: String,
        optional: true
    },
    twitterFriend: { // this field
        type: Object,
        optional: true,
        blackbox: true
    }
}));

See SimpleSchema docs for reference.

Ian Jones
  • 1,369
  • 1
  • 10
  • 15
  • this doesn't seem to work at all, it's like SimpleSchema just ignores blackbox? – Jan Oct 10 '16 at 17:24
  • @Jan You might have to post your code in another question, then link us to it. Maybe something else is slightly off? – Ian Jones Oct 11 '16 at 21:13