Meteor.publish("commonareas.details", function(commonareaId) { if (!this.userId) return null; let user = Meteor.users.findOne(this.userId); return [ CommonAreas.find(commonareaId), CommonAreasSchedules.find({commonareaId: commonareaId, status: "open"}), Meteor.users.find({buildingId: user.buildingId}), ]; });
'Characters.toggleSkill': function(id, skill) { const character = Characters.findOne(id); if (character.skills[skill]) { Characters.update(id, { $unset: { [`skills.${skill}`]: '' } }); } else { Characters.update(id, { $set: { [`skills.${skill}`]: 1 } }); } },
Meteor.publish( 'connectedMembers', function( memberNameArray ) { check( memberNameArray, Match.OneOf( Array, null, undefined ) ); let projection = { fields: { name: 1, city: 1, "profile.description": 1, accountType: 1, lat: 1, lng: 1, network: 1, } }; if (memberNameArray.length > 0) { query = { name: { $in: memberNameArray } } // example of finished query //{ city: { $in: ['San Luis Obispo', 'Avila'] } } }; return NetworkMembers.find( query, projection ); });
Meteor.publish( 'networkSearch', function( search ) { check( search, Match.OneOf( Array, null, undefined ) ); let query = {}, projection = { fields: { name: 1, city: 1, "profile.description": 1, accountType: 1, lat: 1, lng: 1, network: 1, } }; if (search.length > 0) { query = { accountType: { $in: search } } // example of finished query //{ city: { $in: ['San Luis Obispo', 'Avila'] } } }; return NetworkMembers.find( query, projection ); });
'updateMember': (modifier, documentId) => { // TODO change this check to be for user permision and data integrity // check( doc, NetworkMembers.simpleSchema() ); NetworkMembers.update(documentId, modifier); console.log('doc updated'); },
'deleteMember': (docId) => { // TODO change this check to be for user permision // check( doc, NetworkMembers.simpleSchema() ); NetworkMembers.remove(docId); console.log('doc delete'); },
Meteor.publish('tasks', function tasksPublication() { return Tasks.find({ $or: [ { private: { $ne: true } }, { owner: this.userId }, ], }); });
Meteor.publish('lists', function listsPublication() { return Lists.find({ $or: [ {private: { $ne: true}}, {owner: this.userId}, ], }); });
'product.insert': function() { return Products.insert({ sku: '', name: '', image: 'http://dummyimage.com/600x400', summary: '', description: '', price: '', createdAt: new Date(), ownerId: this.userId }) },
Meteor.publish('needs', function () { return Needs.find( {}, { fields: { address: 1, avatar: 1, body: 1, created: 1, email: 1, needPicture: 1, screenName: 1, urgent: 1, userId: 1, userName: 1 } } ); })
Meteor.publish( 'memberSearch', function( search ) { check( search, Match.OneOf( String, null, undefined ) ); let query = {}, projection = { limit: 10, sort: { name: 1 } }; if ( search ) { let regex = new RegExp( search, 'i' ); query = { $or: [ { accountType: regex }, ] }; projection.limit = 100; } return NetworkMembers.find( query, projection ); });
'emailToColleagues': function(options){ var host = this.connection.httpHeaders.host; var candidate = Candidates.findOne({_id:options.candidateId}); var position = Positions.findOne({_id: options.positionId}); for(var i =0; i <= options.emails.length; i++){ if (options.emails[i]){ var number = i + 1; Email.send({ to: options.emails[i], from: 'Bikram Basnet <*****@*****.**>', subject: 'Recommendation ✔', html: '<div>Hi, ' + candidate.name + ' wants you to get your recommendation for the position ' + position.name + '. Please Click Recommend to write more about him<br><a href="https://'+ host +'/#/reference/'+ options.positionId + '/' + options.candidateId + '/' + number + '">Recommend</a></div>' }); } } return { success: 1, message: 'Successfully sent email' } }
'product.remove': function(productId) { return Products.remove(productId) },
'product.update.price': function(productId, price) { return Products.update(productId, { $set: { price } }) },
'product.update.description': function(productId, description) { return Products.update(productId, { $set: { description } }) },
'product.update.name': function(productId, name) { return Products.update(productId, { $set: { name } }) },
import { Mongo } from 'meteor/mongo' import ProductImages from './product_images' const Products = new Mongo.Collection('products') Meteor.methods({ 'product.insert': function() { return Products.insert({ sku: '', name: '', image: 'http://dummyimage.com/600x400', summary: '', description: '', price: '', createdAt: new Date(), ownerId: this.userId }) }, 'product.update.name': function(productId, name) { return Products.update(productId, { $set: { name } }) }, 'product.update.description': function(productId, description) { return Products.update(productId, { $set: { description } }) }, 'product.update.price': function(productId, price) { return Products.update(productId, { $set: { price } }) }, 'product.remove': function(productId) { return Products.remove(productId) },
Meteor.startup(function () { Customer.schema.i18n("pos.customer.schema"); Customer.attachSchema(Customer.schema); });
Products.featured = function(){ var featuredSkus = ["honeymoon-mars","johnny-liftoff","one-way-reentry"]; return Products.find({sku : {$in : featuredSkus}}, {fields : {inventory : false, cost : false}}); };
import { Meteor } from 'meteor/meteor'; import { Mongo } from 'meteor/mongo'; import { check } from 'meteor/check'; //user authentication validation export const Tasks = new Mongo.Collection('tasks'); if(Meteor.isServer) { //this code only runs on the server Meteor.publish('tasks', function tasksPublication() { return Tasks.find({ $or: [{ private: { $ne: true } }, { owner: this.userId }, ], }); }); } //contains all methods related to modifying data in the db Meteor.methods({ 'tasks.insert' (text) { check(text, String); if(!Meteor.userId()) { throw new Meteor.Error('not-authorized'); } Tasks.insert({ text, createdAt: new Date(), owner: Meteor.userId(),
import { Meteor } from 'meteor/meteor'; import { Mongo } from 'meteor/mongo'; import { check } from 'meteor/check'; export const Clubs = new Mongo.Collection('clubs'); Meteor.methods({ 'clubs.insert'(clubname, coins, location) { // Make sure the user is logged in before inserting a task if (! Meteor.userId()) { throw new Meteor.Error('not-authorized'); } Clubs.insert({ clubname, coins : parseInt(coins), location, members : [], staffs: [], buildings : [], contracts : [], songs : [], actionPoints : 10, daycount : 1, owner : Meteor.userId(), username : Meteor.user().username, createdAt : new Date(), }) console.log("club created!") return false; },
import { Meteor } from 'meteor/meteor'; import { Mongo } from 'meteor/mongo'; import { check } from 'meteor/check'; export const Tasks = new Mongo.Collection('tasks'); Meteor.methods({ 'tasks.insert'(text) { check(text, String); // Make sure the user is logged in before inserting a task if (! Meteor.userId()) { throw new Meteor.Error('not-authorized'); } Tasks.insert({ text, createdAt: new Date(), owner: Meteor.userId(), username: Meteor.user().username, }); }, 'tasks.remove'(taskId) { check(taskId, String); Tasks.remove(taskId); }, 'tasks.setChecked'(taskId, setChecked) { check(taskId, String); check(setChecked, Boolean);
import { Mongo } from 'meteor/mongo'; import { CollectionNames } from '../constants.js'; import { NotificationsSchema } from '../schemas/notifications-schema.js'; const Notifications = new Mongo.Collection(CollectionNames.NOTIFICATIONS); Notifications.attachSchema(NotificationsSchema); export { Notifications };
'product.update.image': function(productId, result) { const imageLoc = `/cfs/files/ProductImages/${result}` Products.update(productId, { $set: { image: imageLoc } }) }
Products.bySku = function(sku){ return Products.findOne({sku : sku}); };
import { Mongo } from 'meteor/mongo'; import { chartsSchema, dashboardsSchema, chartsLocationsSchema } from './schemas/'; const Charts = new Mongo.Collection('charts'); const Dashboards = new Mongo.Collection('dashboards'); const ChartsLocations = new Mongo.Collection('chartsLocations'); Dashboards.attachSchema(dashboardsSchema); ChartsLocations.attachSchema(chartsLocationsSchema); // Charts.attachSchema(chartsSchema); // TODO Oleg: add Charts Schema export { Charts, Dashboards, ChartsLocations };
import { Mongo } from 'meteor/mongo'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; const Blogs = new Mongo.Collection('blogs'); Blogs.attachSchema(new SimpleSchema({ title: { type: String, max: 50 }, preview: { type: String, max: 100, autoValue: function() { if(this.field('content').isSet) { return this.field('content').value; } else { this.unset(); // Prevent user from supplying their own value } }, optional: true }, content: { type: String, max: 2000 }, tag: { type: String, defaultValue: 'none' }, createdAt: {
import { Mongo } from 'meteor/mongo'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { Factory } from 'meteor/dburles:factory'; export const Sequence = new Mongo.Collection('sequence'); Sequence.allow({ insert: () => false, update: () => false, remove: () => false }); Sequence.deny({ insert: () => true, update: () => true, remove: () => true }); Sequence.Schema = new SimpleSchema({ _id:{ type:String, label: "the name of document that will use increment value" }, seq:{ type:Number, label: "the value of the Sequence" } }); Sequence.attachSchema(Sequence.Schema);
Meteor.publish('Hindrances', function () { return Hindrances.find(); });
import { Mongo } from 'meteor/mongo'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { STATUS_TYPES, STATUS_AUTO_FORM, STATUS_NORMAL } from '../constants'; const C_Projects = new Mongo.Collection('projects'); const schema = new SimpleSchema({ authorId: { type: String, label: "Developer Id" }, secureToken: { type: String, label: "Developer secure token" }, authorName: { type: String, label: "Developer name", optional: true }, name: { type: String }, desc: { type: String, label: "Description", optional: true }, image: {