Skip to content

Commit

Permalink
Fixes routes and collections boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandesigner committed Sep 22, 2017
1 parent 8e9a5c4 commit 766faf5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 80 deletions.
19 changes: 16 additions & 3 deletions boilerplate/src/imports/api/collections.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { Mongo } from 'meteor/mongo'

export const Events = new Mongo.Collection('events')
export const Coverages = new Mongo.Collection('coverages')
export const Messages = new Mongo.Collection('messages')
export const CollectionName = new Mongo.Collection('collectionName');

const collections = Mongo.Collection.getAll()
console.log(collections)

// collections.allow({
// insert: () => false,
// update: () => false,
// remove: () => false,
// })

// collections.deny({
// insert: () => true,
// update: () => true,
// remove: () => true,
// })
64 changes: 7 additions & 57 deletions boilerplate/src/imports/api/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,33 @@ import { SimpleSchema } from 'meteor/aldeed:simple-schema'

// Collections
import {
Events,
Coverages,
Messages
CollectionName,
} from './collections'

Meteor.methods({

// Events
['events.add'] (args) {
// CollectionName
['collectionName.add'] (args) {
new SimpleSchema({
name: { type: String },
}).validate(args)

const { name } = args

Events.insert({
CollectionName.insert({
name,
created: new Date(),
})
},

['events.remove'] (args) {
['collectionName.remove'] (args) {
new SimpleSchema({
_id: { type: String },
}).validate(args)

const { _id } = args

Events.remove(_id)
},

// Coverages
['coverages.add'] (args) {
new SimpleSchema({
name: { type: String },
}).validate(args)

const { name } = args

Coverages.insert({
name,
created: new Date(),
})
},
CollectionName.remove(_id)
}

['coverages.remove'] (args) {
new SimpleSchema({
_id: { type: String },
}).validate(args)

const { _id } = args

Coverages.remove(_id)
},

// Messages
['messages.add'] (args) {
new SimpleSchema({
text: { type: String },
}).validate(args)

const { name } = args

Messages.insert({
name,
created: new Date(),
})
},

['messages.remove'] (args) {
new SimpleSchema({
_id: { type: String },
}).validate(args)

const { _id } = args

Messages.remove(_id)
},

})
24 changes: 4 additions & 20 deletions boilerplate/src/imports/api/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,12 @@ import { Meteor } from 'meteor/meteor'

// Collections
import {
Events,
Coverages,
Messages
CollectionName
} from './collections'

// Events
Meteor.publish('events', function (limit) {
return Events.find({}, {
sort: { created: -1 }
})
})

// Coverages
Meteor.publish('coverages', function () {
return Coverages.find({}, {
sort: { created: -1 }
})
})

// Messages
Meteor.publish('messages', function () {
return Messages.find({}, {
// Collection Name
Meteor.publish('collectionName', function () {
return CollectionName.find({}, {
sort: { created: -1 }
})
})

0 comments on commit 766faf5

Please sign in to comment.