Questions tagged [meteor-collection-hooks]
14 questions
2
votes
1 answer
Meteor Collection-hooks not working for external DB modifications
I have a bunch of sensors scattered around.
These sensors transmit their status whenever they detect a change in their environment.
The data goes to a server(built using Java) where it processes that information then inserts it into a mongoDB.
My…

scriptkid
- 53
- 8
2
votes
2 answers
Meteor: how to automatically populate field with length of array stored in other field in a collection?
I have a collection defined with SimpleSchema/Collection2 like this:
Schema.Stuff = new SimpleSchema({
pieces: {
type: [Boolean],
},
num_pieces: {
type: Number,
},
How can I get num_pieces to automatically be…

Alveoli
- 1,202
- 17
- 29
2
votes
2 answers
Add id of new document to array in existing document using collection-hooks
I've used matb33:collection-hooks to insert a document after inserting into another, is it possible to update an existing document following an insert? I'm trying to do the following:
within a template Box, whose data context has an _id of boxId,…

Bren
- 273
- 1
- 18
2
votes
0 answers
Execution order of meteor-collection-hook and simple-schema validation is different on the server and the client
I am using collection2, simple-schema and meteor-collection-hooks.
First test
// posts.js
Posts = new Mongo.Collection("posts");
Posts.before.insert((userId, doc) => {
console.log('Should see…

Benjamin Crouzier
- 40,265
- 44
- 171
- 236
1
vote
1 answer
Server side timer after meteor collection is updated
I'm currently developping a simple realtime multiplayer game and i'm stuck with the timer logic.
When there are enough players in a game, the status of the game is set to "STARTED" and from there i want to start a 10 seconds timer and show it to all…

El Poisen
- 121
- 1
- 8
1
vote
1 answer
Router doesn't receive Collection object to route to the Collection document
I have ran into a recent problem where my router doesn't seem to have the collection to route the name.
I have a collection named Nodes. In this collection there are many reading from many nodes with various kinds of data in each node. Although the…

mjwrazor
- 1,866
- 2
- 26
- 42
1
vote
1 answer
Meteor Autoform, collection hooks - How to insert into user profile array after a collection insert?
I'm trying to insert into a user profile array after an autoform inserts into another collection (Meteor.users).
My simple schema array is set up like this -
(within the profile schema)
listings: {
type: [String],
optional: true
},
"listings.$.id":…

Pat
- 225
- 3
- 11
1
vote
0 answers
Angular Meteor 1.3 - Collection Helpers
I'm trying to get the most excellent dburles/meteor-collection-helpers package working with Angular Meteor 1.3. I have two collections.
Lists.attachSchema(new SimpleSchema({
title: {
type: String
},
archived: {
type: Boolean
}
…

sauce
- 592
- 4
- 9
- 25
0
votes
2 answers
meteor collection hooks updating element on a position in array
i have this object:
card: { customFields [ { id, value }, {id , value } ... ] }
A customFields array is inside cards, which contans elements consisting of an id and a value.
Now i want to update a certain element inside of the array, which can be…

Gobliins
- 3,848
- 16
- 67
- 122
0
votes
1 answer
Collection Insert within Collection-Hook bypasses SimpleSchema
I know there are issues opened over Collection-Hooks not working nicely with SimpleSchema. The issue seems to be that SimpleSchema runs before Collection-Hooks.
But in the following example, I am inserting a document into a completely different…

Omgabee
- 97
- 10
0
votes
1 answer
meteor collection hooks: get context of $set operation on field in array
I have a collection that contains an array of objects; schema looks like the following:
Boards.attachSchema(new SimpleSchema({
[...]
'members.$.userId': {
type: String,
},
'members.$.isActive': {
type: Boolean,
},
[...]
Now I…

Adrian Genaid
- 416
- 5
- 17
0
votes
2 answers
collection hook not called on second application
I have an application written with Meteor 1.4 and run it on port 3000 (called A) know I want use A application database in another application (called B). In B console I set MONGO_URL like this:
export MONGO_URL=mongodb://localhost:3001/meteor
And…

b24
- 2,425
- 6
- 30
- 51
0
votes
1 answer
Updating total from quantity and price in Meteor collection
I have three fields quantity, price, and total.
I am only updating quantity and price, so total should be calculated automatically.
How can I make sure total is always updated correctly? I guess I should use a collection hook.

Jamgreen
- 10,329
- 29
- 113
- 224
-1
votes
1 answer
Howto interrupt meteor collections insert in the before hook?
How can i interrupt an insert by checking some condition in the before hook?
Collection.before.insert((userId, doc) => {
if(doc.property != valid){
// interrupt insert here
}
});
i tried throw new Meteor.Error('Insert Error','Not…

Gobliins
- 3,848
- 16
- 67
- 122