/deta-queue

Queue for use with deta base.

Primary LanguageTypeScriptMIT LicenseMIT

deta-queue

npm package Build Status Downloads Issues

Queue for use with deta base.

Install

npm install deta-queue

Usage

import { Queue } from 'deta-queue';
import { Deta } from 'deta';

// Initialize with a Project Key
const deta = Deta(process.env.DETA_PROJECT_KEY); 

const queue = new Queue(deta);

async function main() {

	await queue.empty();

	const items = ["test1", "test2", "test3", "test4", "test5"]

	for (let index = 0; index < items.length; index++) {
		const element = items[index];
		await queue.push(element);
	}

	const item = queue.pop(1);

	console.log(item);
}

main();
//=> 'test1'

API

Queue(deta: Deta, ttl?: number = 606024*14, queueName?: string = "queue")

deta

Type: object

Deta object

ttl

Type: number

expireIn for the Deta Base Item

queueName

Type: string Default: queue

Base Name for the Queue Deta Bases