12
votes

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.

1

1 Answers

20
votes

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.