How to use the meteor/mongo.Mongo.Collection function in meteor

To help you get started, we’ve selected a few meteor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CommonGarden / Grow-IoT / imports / api / collections / things.js View on Github external
import { Mongo } from 'meteor/mongo';

// Create a collection where users can only modify documents that
// they own. Ownership is tracked by an 'owner' field on each
// document. All documents must be owned by the user that created
// them and ownership can't be changed. Only a document's owner
// is allowed to delete it, and the 'locked' attribute can be
// set on a document to prevent its accidental deletion.
Things = new Mongo.Collection('Things');
Things.allow({
  insert: function (userId, doc) {
    // the user must be logged in, and the document must be owned by the user
    return (userId && doc.owner === userId);
  },
  update: function (userId, doc, fields, modifier) {
    // can only change your own documents
    return doc.owner === userId;
  },
  remove: function (userId, doc) {
    // can only remove your own documents
    return doc.owner === userId;
  },
  fetch: ['owner']
});
Things.deny({
github ACGN-stock / acgn-stock / db / dbCompanyArchive.js View on Github external
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import SimpleSchema from 'simpl-schema';

// 公司保管庫資料集
export const dbCompanyArchive = new Mongo.Collection('companyArchive');
export default dbCompanyArchive;

const schema = new SimpleSchema({
  // 保管狀態
  status: {
    type: String,
    allowedValues: ['archived', 'foundation', 'market']
  },
  // 公司名稱
  name: {
    type: String
  },
  // 相關搜索用Tag
  tags: {
    type: Array,
    maxCount: 50
github erxes / erxes / imports / api / knowledgebase / collections.js View on Github external
import { Mongo } from 'meteor/mongo';
import { Brands } from '/imports/api/brands/brands';
import { KbAutoFieldSchema, KbTopicsSchema, KbCategoriesSchema, KbArticlesSchema } from './schema';

/* ----------------------- Collections ----------------------- */
export const KbTopics = new Mongo.Collection('knowledgebase_topics');
export const KbCategories = new Mongo.Collection('knowledgebase_categories');
export const KbArticles = new Mongo.Collection('knowledgebase_articles');

KbTopics.attachSchema(KbAutoFieldSchema);
KbTopics.attachSchema(KbTopicsSchema);

KbCategories.attachSchema(KbAutoFieldSchema);
KbCategories.attachSchema(KbCategoriesSchema);

KbArticles.attachSchema(KbAutoFieldSchema);
KbArticles.attachSchema(KbArticlesSchema);

KbTopics.helpers({
  brand() {
    return Brands.findOne(this.brandId) || {};
  },
});
github lacymorrow / cinematic / imports / startup / server / database.js View on Github external
'use strict'

import {Meteor} from 'meteor/meteor'
import {Mongo} from 'meteor/mongo'

import {epoch} from '../both/util'

export const Genres = new Mongo.Collection('genres')
export const Movies = new Mongo.Collection('movies')
export const MovieCache = new Mongo.Collection('movieCache')
export const State = new Mongo.Collection('state')
export const Recent = new Mongo.Collection('recent')
export const Watched = new Mongo.Collection('watched')

/* State */
export const initState = options => {
	const defaults = {
		_id: '0', // There can be only one...
		cwd: process.env.PWD,
		dir: '~/',
		loading: 100,
		queueTotal: 0
	}
	return State.insert(Object.assign(defaults, options))
}
github coin-worx / ether-wallet / collections / projects.collection.ts View on Github external
import {Mongo} from 'meteor/mongo';

export let Projects = new Mongo.Collection('projects');

Projects.allow({
	insert: function(){
		let user = Meteor.user();

		return !!user;
	},
	update: function(){
		let user = Meteor.user();

		return !!user;
	},
	remove: function(){
		let user = Meteor.user();

		return !!user;
github reactioncommerce / reaction / imports / plugins / included / csv-connector / lib / collections / collections.js View on Github external
import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import * as Schemas from "./schemas";

/**
 * @name JobItems
 * @memberof Collections
 * @type {MongoCollection}
 */
export const JobItems = new Mongo.Collection("JobItems");

JobItems.attachSchema(Schemas.JobItems);

/**
 * @name Mappings
 * @memberof Collections
 * @type {MongoCollection}
 */
export const Mappings = new Mongo.Collection("Mappings");

Mappings.attachSchema(Schemas.Mappings);

/**
 * Meteor Mongo.Collection instances that are available only in browser code
 * @namespace Collections/ClientOnly
 */
github thm-projects / arsnova-flashcards / imports / api / authors.js View on Github external
import {Meteor} from "meteor/meteor";
import {Mongo} from "meteor/mongo";

export const Authors = new Mongo.Collection("authors");

if (Meteor.isServer) {
	Meteor.publish("authors", function () {
		return Authors.find();
	});
}
github zencrepes / zencrepes / imports / ui / data / Minimongo.js View on Github external
export const cfgProjects = new Mongo.Collection("cfgProjects", {
  connection: null
});
//export const localCfgQueries = new PersistentMinimongo2(cfgQueries, 'GAV-Queries');
window.projects = cfgProjects;

export const cfgCards = new Mongo.Collection("cfgCards", { connection: null });
window.cards = cfgCards;

export const cfgRepositories = new Mongo.Collection("cfgRepositories", {
  connection: null
});
window.repos = cfgRepositories;

export const cfgTeams = new Mongo.Collection("cfgTeams", {
  connection: null
});
window.teams = cfgTeams;
github Meteor-Community-Packages / meteor-user-status / demo / client / main.js View on Github external
import { Handlebars } from 'meteor/blaze';
import { Meteor } from 'meteor/meteor';
import { TimeSync } from 'meteor/mizzao:timesync';
import { Mongo } from 'meteor/mongo';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import { UserStatus } from 'meteor/mizzao:user-status';
import moment from 'moment';

import './main.html';

const UserConnections = new Mongo.Collection('user_status_sessions');

const relativeTime = (timeAgo) => {
  const diff = moment.utc(TimeSync.serverTime() - timeAgo);
  const time = diff.format('H:mm:ss');
  const days = +diff.format('DDD') - 1;
  const ago = (days ? days + 'd ' : '') + time;
  return `${ago} ago`;
};

Handlebars.registerHelper('userStatus', UserStatus);
Handlebars.registerHelper('localeTime', date => date != null ? date.toLocaleString() : undefined);
Handlebars.registerHelper('relativeTime', relativeTime);

Template.login.helpers({
  loggedIn() {
    return Meteor.userId();