More work with subscriptions
This commit is contained in:
parent
316e14f0ea
commit
918103a17b
12 changed files with 29 additions and 14 deletions
|
|
@ -39,12 +39,12 @@ Subscriptions.deny({
|
|||
|
||||
Subscriptions.schema = new SimpleSchema({
|
||||
location: Object,
|
||||
'location.lat': SimpleSchema.Integer,
|
||||
'location.lon': SimpleSchema.Integer,
|
||||
'location.lat': Number,
|
||||
'location.lon': Number,
|
||||
distance: Number,
|
||||
owner: String
|
||||
});
|
||||
|
||||
// Subscriptions.attachSchema(Subscriptions.schema);
|
||||
Subscriptions.attachSchema(Subscriptions.schema);
|
||||
|
||||
export default Subscriptions;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Meteor.methods({
|
|||
},
|
||||
'subscriptions.update': function subscriptionsUpdate(doc) {
|
||||
check(doc, {
|
||||
_id: String,
|
||||
_id: Meteor.Collection.ObjectID,
|
||||
location: Match.ObjectIncluding({ lat: Number, lon: Number }),
|
||||
distance: Number
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* eslint-disable prefer-arrow-callback */
|
||||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
import Perlin from 'loms.perlin';
|
||||
import Subscriptions from '../Subscriptions';
|
||||
|
||||
|
|
@ -42,5 +44,7 @@ Meteor.publish('subscriptions', function subscriptions() {
|
|||
// Note: subscriptions.view is also used when editing an existing subscription.
|
||||
Meteor.publish('subscriptions.view', function subscriptionsView(subscriptionId) {
|
||||
check(subscriptionId, String);
|
||||
return Subscriptions.find({ _id: subscriptionId, owner: this.userId });
|
||||
const id = new Mongo.ObjectID(subscriptionId);
|
||||
check(id, Meteor.Collection.ObjectID);
|
||||
return Subscriptions.find({ _id: id, owner: this.userId });
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue