moment-to-reql

A helper function to convert moment.js object to ReQL so that Timezone information can be preserved when passing data to RethinkDB.

Usage no npm install needed!

<script type="module">
  import momentToReql from 'https://cdn.skypack.dev/moment-to-reql';
</script>

README

moment-to-reql

GratiPay Downloads Version

A helper function to convert moment.js object to ReQL so that Timezone information can be preserved when passing data to RethinkDB.

Installation

moment-to-reql expects that you have already installed moment and moment-timezone.

npm instal --save-dev moment-to-reql

Usage

Returned value can be used in place of regular Date, r.now() and all other time/date objects in your ReQL queries:

import momentToReQL from 'moment-to-reql';

momentToReQL(moment.tz('10/10/2010 10:00', 'DD/MM/YYYY hh:mm', 'America/Los_Angeles');
// returns:
//  {
//    $reql_type$: 'TIME',
//    epoch_time: 1286730000,
//    timezone: '-07:00',
//  }

License

ISC