Example #1
0
 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');
  },
Example #7
0
 Meteor.publish('tasks', function tasksPublication() {
   return Tasks.find({
     $or: [
       { private: { $ne: true } },
       { owner: this.userId },
     ],
   });
 });
Example #8
0
	Meteor.publish('lists', function listsPublication() {
		return Lists.find({
			$or: [
				{private: { $ne: true}},
				{owner: this.userId},
			],
		});
	});
Example #9
0
 'product.insert': function() {
   return Products.insert({
     sku: '',
     name: '',
     image: 'http://dummyimage.com/600x400',
     summary: '',
     description: '',
     price: '',
     createdAt: new Date(),
     ownerId: this.userId
   })
 },
Example #10
0
 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 );
  });
Example #12
0
		'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'
			}
		}
Example #13
0
 'product.remove': function(productId) {
   return Products.remove(productId)
 },
Example #14
0
 'product.update.price': function(productId, price) {
   return Products.update(productId, { $set: { price } })
 },
Example #15
0
 'product.update.description': function(productId, description) {
   return Products.update(productId, { $set: { description } })
 },
Example #16
0
 'product.update.name': function(productId, name) {
   return Products.update(productId, { $set: { name } })
 },
Example #17
0
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)
  },
Example #18
0
Meteor.startup(function () {
    Customer.schema.i18n("pos.customer.schema");
    Customer.attachSchema(Customer.schema);
});
Example #19
0
Products.featured = function(){
  var featuredSkus = ["honeymoon-mars","johnny-liftoff","one-way-reentry"];
  return Products.find({sku : {$in : featuredSkus}},
    {fields : {inventory : false, cost : false}});
};
Example #20
0
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(),
Example #21
0
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;
  },
Example #22
0
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);
 
Example #23
0
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 };
Example #24
0
 'product.update.image': function(productId, result) {
   const imageLoc = `/cfs/files/ProductImages/${result}`
   Products.update(productId, { $set: { image: imageLoc } })
 }
Example #25
0
Products.bySku = function(sku){
  return Products.findOne({sku : sku});
};
Example #26
0
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 };
Example #27
0
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();
 });
Example #30
0
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: {