Подтвердить что ты не робот

Хранение произвольного объекта внутри поля с простой схемой метеор

У меня есть схема с полем type: Object. Но всякий раз, когда я делаю вставку, этот объект пуст.

Вот моя схема

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

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

Даже если do Contacts.insert({firstName: 'Mustafa', twitterFriend: {test: 'this should be stored'}}). Это не работает.

4b9b3361

Ответ 1

Для объекта произвольной подсхемы вы устанавливаете blackbox: true

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

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

См. SimpleSchema docs для справки.