alon:ejson-moment
A Meteor package that adds a Moment.js objects as custom EJSON type.
This allows Moment objects to be transmitted over DDP, which allows you to:
- publish Moment instances of if you pass them to publish handlers.
- use Moment instances in the return values or arguments to methods.
- store Moment instances client-side in Minimongo.
- allowing your type in reactive variables.
Installation
$ meteor add alon:ejson-moment
Table of Contents
Examples
var momentInstance = moment();
method call
Server:
Meteor.methods({
getMoment: function (m) {
var ret = moment();
var Moment = ret.constructor;
var isMoment = m instanceof Moment;
console.log('called getMoment. The argument is a Moment? %b.', isMoment);
return ret;
}
});
Client:
Meteor.call('getMoment', moment(), function (err, result) {
console.log(result);
});