Blame view
imports/collections/students/methods.js
1.7 KB
d0099dd88
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
// import { } from '/imports/collections/students/methods'; import _ from 'lodash'; import { Meteor } from 'meteor/meteor'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Bert } from 'meteor/themeteorchef:bert'; import { Users } from '/imports/collections/users/index'; import { Students } from '/imports/collections/students/index'; import { Orgs } from '/imports/collections/orgs/index'; export const studentMethods = new ValidatedMethod({ name: 'student.method', validate: new SimpleSchema({ itemId: { type: String }, }).validator(), run({itemId}) { return {}; }, }); export const addStudentManually = new ValidatedMethod({ name: 'student.addManually', validate: new SimpleSchema({ firstName: { type: String }, middleName: { type: String }, lastName: { type: String }, }).validator(), run({firstName,middleName,lastName}) { console.log(firstName); console.log(middleName); console.log(lastName); const user = Users.findOne({_id: this.userId}); orgId = user.orgId; newUserId = Users.insert({ username: firstName, firstName: firstName, middleName: middleName, lastName: lastName, orgId: orgId, role: 'STUDENT' }); log(newUserId); if(newUserId){ Students.insert({ userId: newUserId, orgId: orgId, }); } return {newUserId}; }, }); |