Skip to content

A mongodb stitch app that runs as a cron service.

License

Notifications You must be signed in to change notification settings

OrthoDex/mongo-stitch-cron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Stitch Cron

A simple stitch app to run as a cron service on MongoDB Stitch, using MongoDB TTL.

Powered by Stitch

This repository contains a stitch app configured as a database trigger for a DELETE event.

The DELETE event occurs when a document within a collection containing a TTL index is deleted. The app then inserts a new document into the collection with the current date, thus causing a rough timed loop.

Setup

  stitch-cli login --username=<MongoDB Cloud username> --api-key=<MongoDB Atlas API Key>
  • Modify the code in source.js to your needs. Ensure that you re-insert the deleted key back into the database.

  • Deploy the stitch app and link it to your cluster:

stitch-cli import
  • Install dependencies:
yarn install
  • Setup the database TTL index and insert a document.
  MONGODB_HOST=<your mongodb connection string> node setup.js

You can view the logs for the stitch app in the left side of your stitch app dashboard.

Resources

Resource Description
Stitch Docs MongoDB Stitch Documentation
MongoDB Docs MongoDB Documentation
MongoDB Community Slack MongoDB Community Slack
DatabaseTriggers Setting up Stitch apps as database triggers
Database TTL Expire data from a collection by setting a TTL

About

A mongodb stitch app that runs as a cron service.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published