
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Simple abstractions for storing complex JSON data in Redis. Supports storage of complex objects and arrays.
const Redis = require('ioredis');
const { Rejects } = require('rejects');
const r = new Redis();
const s = new Rejects(r);
s.set('some key', {
id: 'some id',
array: [
'array',
'of',
'primitives',
{
and: 'an',
object: 'too',
},
],
data: {
complex: 'nested',
data: 'here',
with: [
'an',
'array',
],
},
});
Nested data can be directly accessed and modified by concatentating properties together with a .
. For example:
const data = await s.get('some key'); // { id: 'some id', ... }
const with = await s.get('some key.data.with', { type: 'arr' }); // ['an', 'array']
const update = await s.set('some key.data.with', ['new', 'array']);
const added = await s.upsert('some key.data.with', ['element']);
Note that the type must be explicitly set to arr
when directly accessing an array. Upserts are faster than sets, as they do not have to clear out the existing data before adding new data.
References to other data can be created:
const { Reference } = require('rejects');
await s.set('some other key', {
value: 'hello world',
});
await s.set('some key', {
id: 'an id',
reference: new Reference('some other key.value'),
});
const data = await s.get('some key'); // { id: 'an id', reference: 'hello world' }
References can be created within arrays to create arrays of references. The Reference
constructor takes a second parameter of either obj
or arr
to differentiate between references to arrays and objects (default to obj
).
default
constructor(redis: Redis)
- make a new instance and give it an ioredis clientget(key: string, { full = true, type = 'obj', depth = -1 })
- get a complex object. Valid type values are arr
and obj
depending on the anticipated data type of the fetched data. If full is true, will resolve all references to nested data. If full is false, will set the property to a string of the form ref:<type>:<key>
where type is arr
or obj
, and key
points to the Redis key where the data is stored. Setting a depth option of 0 or greater will ensure recursion to only the specified depth.set(key: string, data: any)
- set complex data; will overwrite and remove existing data that is changed or removed in the new data.upsert(key: string, data: any)
- set complex data; will overwrite but not remove existing data.delete(key: string)
- delete all complex data at a given key.keys(key: string)
- get the keys of the object at key
.size(key: string)
- get the size of the object at key
.incr(key: string, count = 1)
- increment the value at key
by count
.FAQs
Enable easy object storage in Redis using native types.
We found that rejects 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.