hi guys,
sorry for the disturb I am very new in meteorjs, so please be bear on me.
I have two collection Item and Product which is one to one relationship, I know the basic insert data in collection,
All I really want to do is to simultaneously insert two inserted collections by just one form. for example when it’s normal to insert I can insert it using a form and one collection. but what I just wanted is the Item collection and Product colletion are in a form … I have tried meteor.call but is not working for me, any idea for this ?
sorry for my stupid question I just want to get rid of this …
// Meteor Package(s)
import { Meteor } from 'meteor/meteor';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
// Collection
import { Items } from './items.js';
import { Products } from '/imports/api/products/products.js';
Meteor.methods({
'items.insert': function(itemData) {
new SimpleSchema({
name: {type: String},
category: {type: String},
productId: {type: String},
productName: {type: String},
}).validate( itemData );
if (!this.userId) {
throw new Meteor.Error(error.reason);
}
try {
Items.insert({
name: itemData.name,
category: itemData.category,
productId: itemData.productId,
productName: itemData.productName,
createdAt: new Date(),
deletedAt: null,
});
} catch(error) {
throw new Meteor.Error('error', error.error);
}
Meteor.call('products.insert')
},
});