Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
corrieneuch-sequelize
Advanced tools
Readme
Provides Corrieneuch actions using a Sequelize connection. Only tested with Postres so far.
$ npm install --save corrieneuch-sequelize
## Usage
import * as Corrieneuch from 'corrieneuch';
import DbResourceCollection from 'corrieneuch-sequelize';
let users = new DbResourceCollection(User);
// inside a request handler
users.get('/users/1', 1, new Corrieneuch.QueryOptions(request.query));
constructor(model: EntityModel<TEntity>, relationships: _.Dictionary<EntityRelationship> = {})
Constructor. Pass a Sequelize Model in as the first parameter, which will connect the resource collection to a table in the database.
If you want to support the include
query option with related resources, use
the relationships
field. E.g., for the canonical blog posts with User
entities as authors:
let posts = new DbResource(Post, {
author: {
relationship: {model: User, as: 'author'},
link: '/users/<%=authorId%>'
}
});
The link
field specifies the format of the URL.
list(url: string, options: Corrieneuch.QueryOptions, constraints?): Promise<Corrieneuch.Resource>
Returns a resource with a list of resources as elements. The $self
links will be based off
the supplied URL, with subresources having their ID appended. Currently only number
paging is
supported. offset
paging can also be used, but it must represent a whole number of pages, and
it will be converted to number
paging.
The constraints
parameter is useful in multi-tenant scenarios - passing a filter here will contrain
the list to match the filter.
get(url: string, id: any, options: Corrieneuch.QueryOptions, constraints?): Promise<Corrieneuch.Resource>
Returns a resource with the specified resource as attributes, and the given URL as the $self
link.
If constraints
is given, the item will only be returned if it also matches constraints
.
create(url: string, payload: any, constraints?): Promise<Corrieneuch.Resource>
Creates and returns a resource from the specified request payload. The payload must contain an
attributes
field from which the new resource will be constructed.
If constraints
is given, the payload must match it or an exception will be thrown.
update(url: string, id: any, payload: any, constraints?): Promise<Corrieneuch.Resource>
Updates and returns the resource with the specified ID. Only the fields given in payload.attributes
will be updated. If the given resource isn't found, then null
is returned.
The payload must match constraints
, or an exception will be thrown. Additionally, the existing DB object
must also match constraints
, or null
will be returned.
delete(id: any, constraints?): Promise<number>
Deletes the resource with the specified ID. A count of the number of rows deleted will be returned.
If constraints
is given, the object to be deleted must also match it.
FAQs
A sequelize-powered implementation of Corrieneuch
The npm package corrieneuch-sequelize receives a total of 2 weekly downloads. As such, corrieneuch-sequelize popularity was classified as not popular.
We found that corrieneuch-sequelize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.