Advertisement
bokoness

Bagel cloud function

Mar 9th, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Bagel = require('@bageldb/bagel-db');
  2.  
  3. const db = new Bagel(process.env.BAGEL_TOKEN);
  4. const body = {
  5.     itemID:"o3iuykjs32",
  6.     collectionID:"12po3i7kjbr",
  7.     trigger:"create",
  8.     item:{
  9.         startDate:"1/2/23",
  10.         endDate:"1/2/23",
  11.         isRecurring:true,
  12.         recurringCycle:{_id:"c1296bi23akg00b6e320",value:"Weekly"},
  13.         continueUntil:"14/5/24",
  14.         user:[{
  15.             itemRefID:"1o2u3ikjbsd",
  16.             value:"username"
  17.         }]
  18.     }
  19. }
  20. exports.handler = async (event) => {
  21.     let { item } = JSON.parse(event.body);
  22.  
  23.     if (item.isRecurring) {
  24.  
  25.         let eventStartDate = new Date(item.startDate);
  26.         let eventEndDate = new Date(item.endDate);
  27.         var eventDuration = Math.abs(eventStartDate - eventEndDate) / 216e6; // diff in minutes
  28.  
  29.         let ContinueUntil = new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement