
Research
npm Malware Targets Telegram Bot Developers with Persistent SSH Backdoors
Malicious npm packages posing as Telegram bot libraries install SSH backdoors and exfiltrate data from Linux developer machines.
seneca-entity
Advanced tools
Seneca Entity is a plugin for Seneca
Provides a simple Object-Relation Mapping over Seneca messages as a convenience API for manipulating data.
Any data store can then be accessed using the full power of Seneca messages.
![]() | This open source module is sponsored and supported by Voxgig. |
---|
With npm:
$ npm install seneca-entity
With yarn:
$ yarn add seneca-entity
Implemented using TypeScript. Minimal types are provided by the package.
Please visit senecajs.org for a more complete overview and documentation of the Seneca framework.
Read the Understanding Data Entities tutorial for a step-by-step introduction to Seneca data entities.
const Seneca = require('seneca')
const seneca = Seneca() // Create a new instance of Seneca.
.use('entity') // Use the seneca-entity plugin (Seneca will require it).
// Create an reusable instance of the `person` entity.
const Person = seneca.entity('person')
// Create a specific person instance.
let alice = Person.make$()
// Set some fields (assumes a NoSQL database, or a predefined table).
// Properties with a final `$` are reserved for the Entity API methods.
alice.name = 'Alice'
alice.location = 'Wonderland'
// Save your data. Seneca entity provides a default in-memory store,
// which is very useful for fast unit tests.
alice = await alice.save$()
// The `alice` entity now has an `id` field.
let alsoAlice = await Person.load$(alice.id)
alsoAlice.location = 'Looking Glass'
// The `alsoAlice` entity will be updated, not created, because
// it has an `id` field. The save$ method both creates and updates.
await alsoAlice.save$()
// Entity methods can be chained (until they return a Promise).
let lily = await Person
.make$({
name: 'Lily',
location: 'Looking Glass'
})
.save$()
// The data$ method exports a JSON serializable verson of the entity
// as a plain object.
console.log(lily.data$())
// The data$ method can alternatively set multiple fields.
await lily
.data$({
game: 'chess'
})
.save$()
// List all the person entities.
let people = await Person.list$()
// List only those person entities with field `game` equal to the string "chess".
let players = await Person.list$({game: 'chess'})
Seneca Entity is inspired in part by the ActiveRecord pattern as implemented by Ruby on Rails.
Seneca Entity is not a full Object Relation Mapping. It is a convenience API over the Seneca action patterns:
role:entity,cmd:load
- .load$()
role:entity,cmd:save
- .save$()
role:entity,cmd:list
- .list$()
role:entity,cmd:remove
- .remove$()
This means that you can extend the "ORM" using the same message manipulation as with all Seneca messages, including sending them over the network to other microservices.
In particular, you can:
seneca.message('role:entity,cmd:save,name:person', async function(msg) { ... })
BUT, Seneca entity does not natively implement relations, and loads only the top level entity. Since relation mapping often leads to inefficient queries, this is not such a bad thing. When relations are needed, you can implement them manually by customizing the appropriate action patterns. Or you may find that denormalizing your data is more fun than you think.
Copyright (c) 2012-2022, Richard Rodger and other contributors. Licensed under MIT.
FAQs
Entity plugin for seneca
The npm package seneca-entity receives a total of 4,388 weekly downloads. As such, seneca-entity popularity was classified as popular.
We found that seneca-entity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Malicious npm packages posing as Telegram bot libraries install SSH backdoors and exfiltrate data from Linux developer machines.
Security News
pip, PDM, pip-audit, and the packaging library are already adding support for Python’s new lock file format.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.