Giter VIP home page Giter VIP logo

facet's People

Contributors

bill-kerr avatar mckalexee avatar murtyjones avatar s-fletcher avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

facet's Issues

Replace AWS SDK

Background

Currently @faceteer/facet expects a provisioned instance of Dynamo DB from the aws-sdk.

This causes issues when trying to load the library in non-node environments, like Cloudflare Workers.

Removing the requirement on aws-sdk could make it easier to deploy to multiple places.

Proposal

We use https://github.com/mhart/aws4fetch, and update all of our calls to hit the DynamoDB API directly.

Support a way to differentiate deletes where the item existed or did not exist

When performing deletes, it is useful to be able to differentiate between "this item existed and was deleted" and "this did not exist, and there was nothing to delete". For example, a RESTful DELETE endpoint can return a 404 or 200 based on whether the item already existed or not.

Right now the only way to differentiate between the two is to first perform a lookup then delete, which is not even necessarily accurate since there can be a data race between the two operations.

A better way to do this might be to use the attribute_exists condition with the PK attribute to make the delete fail if the item does not exist.

Migration script

What

Create a script which can be used to iterate through every record in DynamoDB and migrate the data structure. Perhaps this needs its own repository.

Add `delete` to facets.

Delete

We need to add a delete function to our facets.

This function should take an individual item, or an array of items to delete.

If we get an array of items we should use the bulk delete endpoint and iterate through until everything is deleted.

If we get a single item we should allow for a conditional deletes.

Looking at the current implementation for put will be a good idea.

Support facet updates

What

Add support for updating an item within a Facet with update(). This behavior would work similarly as put(), except not all attributes are required.

Allow queries to override the default validator for a facet

Consider a case where you need to bulk delete items from a facet. You can't perform deletes on a query, so you need to instead query for the items you want to delete, then issue deletes on them.

But one problem emerges: say your database includes items that were false and can no longer be validated. You can't query for these items as they will fail the validation, which means you then can't delete them.

A good solution to this problem would be to temporarily override the facet validator on a query. The override could look like this:

const items = await MyFacet.query({ someId }).withValidator((item) => 'someId' in item).list();
MyFacet.delete(items);

Cross Entity Queries

The same partition key can have many different entities inside of it.

To really utilize DynamoDB Faceteer should be able to support this use case.

Default behavior when querying over a sharded index

If a facet is configured to use shards, the default behavior should be to query every shard if none is specified.

Some positive outcomes:

  • Minimizes code when querying all shards (as shown below)
  • Removes anti-pattern to define a shard count in some configuration file to reference outside of facet
  • Allows previous pattern to prevent breaking changes

Before

const promises = [];
for(let i = 0; i < SHARD_COUNT; i++) {
    promises.push(Facet.query({ partition }, i).list());
}
const results = await Promise.all(promises);
const records = results.map((result) => result.records).flat();

After

const { records } = await Facet.query({ partition }).list();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.