Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@luggage/core

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luggage/core

Dropbox file API wrapper for storing json data.

  • 2.2.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

luggage

build status

Dropbox file API wrapper for storing json data.

Have you ever noticed that their stuff is shit and your shit is stuff? (George Carlin)

Usage

const backend = new DropboxBackend(token);
const store = new Luggage(backend);
const articles = store.collection('articles');

Filtering

articles.where({ author: 'John Doe' }).read().then((articles) => {
  console.log('John\'s articles:', articles);
});

/* or you can provide a function */
articles.where(article => article.authors.includes('John Doe')).read().then((articles) => {
  console.log('John\'s articles:', articles);
});

/* Listen to filtered data updates */
articles.where({ author: 'John Doe' }).on('data', (articles) => {
  console.log('John\'s articles:', articles);
});

/* You can stack conditions */
articles.where({ author: 'John Doe' }).where(article => article.comments > 0)

/* or more readable */
articles.where({ author: 'John Doe' }).and(article => article.comments > 0)

Finding single record

/* Collection#find returns the first record found */
articles.find({ author: 'John Doe' }).read().then((article) => {
  console.log('John\'s article:', article);
});

/* Collection#find takes a function */
articles.find(article => article.author === 'John Doe').read().then((article) => {
  console.log('John\'s article:', article);
});

/* Listen to single record updates */
articles.find({ author: 'John Doe' }).on('data', (article) => {
  console.log('John\'s article:', article);
});

Updating record

/* Simple merge with existing record */
articles.find({ id: 1 }).update({ author: 'Jane Doe' }).then(([article]) => {
  console.log('Author changed:', article.author);
});

/* Record#update takes a function (surprise :)) */
articles.find(article => article.id === 42).update((article) => {
  article.authors.push('Jane Doe');
  return article;           // Do not forget to return new record
})

Adding new record

articles.add({ author: 'John Doe', body: 'Blah blah blah mr. Freeman' }).then(([article]) => {
  console.log('New article was added:', article);
});

Deleting record

articles.find({ id: 1 }).delete().then(([article]) => {
  console.log('No longer within collection:', article);
});

FAQs

Package last updated on 17 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc