
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
ts-redis-entity
Advanced tools
A package that helps you to save a simple entity structure to redis. With various features like expire, update with conditions.
A package that helps you to save a simple entity structure to redis. With various features like expire, update with conditions.
The entity structure is saved using hmset.
import {BaseEntity, Column, Entity, tsRedisEntity} from "ts-redis-entity";
@Entity({namespace: "QuickStart", connection: "default"})
class QuickStart extends BaseEntity {
@Column()
public id: string = "";
@Column()
public number: number = 10;
}
async function quickStartExamples() {
await tsRedisEntity.addConnection("default", { port: 6380, host: "127.0.0.1" });
const entity = QuickStart.new({id: "1", number: 10});
await entity.create({expire: 60}); // expire in 60 seconds
const foundEntity = await QuickStart.find("1");
if (foundEntity) {
const getValues = foundEntity.getValues();
foundEntity.setValues({number: 20});
await foundEntity.update({expire: new Date(new Date().getTime() + 60 * 1000)});
}
}
import {BaseEntity, Column, Entity, errorCodes, OperationError, tsRedisEntity} from "ts-redis-entity";
@Entity({namespace: "TestingEntity", connection: "default"})
class TestingEntity extends BaseEntity {
@Column()
public id: string = "";
@Column()
public value: string = "";
@Column()
public number?: number = 0;
@Column()
public date?: Date = new Date();
@Column({parseDate: true})
public object?: any = {};
@Column()
public array?: any[] = [];
@Column()
public boolean?: boolean = false;
@Column()
public nullableString: string | null = null;
}
async function saveIfExamples() {
const entity = await TestingEntity.new({id: "prefix", number: 10}).create();
const foundEntity = await TestingEntity.find("prefix");
entity.number = 11;
await entity.update();
if (foundEntity) {
try {
foundEntity.number = 12;
await foundEntity.updateIf({number: 11});
} catch (err) {
if (err instanceof OperationError) {
console.assert(err.errorCode === errorCodes.conditionNotMatch);
}
}
}
}
async function finaAllExamples() {
const entity1 = await TestingEntity.new({id: "prefix1"}).create();
const entity2 = await TestingEntity.new({id: "prefix2"}).create();
const keys = await TestingEntity.findAllIds("prefix");
// keys = ["prefix1", "prefix2"]
const stream = TestingEntity.scanAllIds("prefix1");
stream.on("data", ids => console.log(ids));
stream.on("end", () => console.log("end"));
}
FAQs
A package that helps you to save a simple entity structure to redis. With various features like expire, update with conditions.
We found that ts-redis-entity 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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.