
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
@sumor/database
Advanced tools
A Sumor Cloud Tool.
More Documentation
A database connector for MySQL, etc. Based on entity.
npm i @sumor/database --save
Require Node.JS version 18.x or above
As this package is written in ES module,
please change the following code in your package.json file:
{
"type": "module"
}
You can use install method to install entity and view to database.
database.install(config, [resource path], [resource data])
case 1: install entity and view from resource path, it will load data/entity and data/view from project root path.
import database from '@sumor/database'
const config = {
host: 'localhost',
user: 'root',
password: 'password',
database: 'database',
port: 3306
}
await database.install(config.database, process.cwd() + '/data')
case 2: install entity and view from resource data, it will load data/entity and data/view from data object.
import database from '@sumor/database'
await database.install(config, {
entity: {
Car: {
property: {
brand: {
type: 'string',
length: 100
},
model: {
type: 'string',
length: 100
}
}
}
},
view: {}
})
import database from '@sumor/database'
const config = {
host: 'localhost',
user: 'root',
password: 'password',
database: 'database',
port: 3306
}
// get client with connection pool
const client = await database.client(config)
// get connection
const db = await client.connect()
// set operate user
db.setUser('tester')
// create record
const car1Id = await db.insert('Car', {
brand: 'BMW',
model: 'X5'
})
const car2Id = await db.insert('Car', {
brand: 'BMW',
model: 'X6'
})
// read record
const car = await db.single('Car', { id: carId })
// car = {id: car1Id, brand: 'BMW', model: 'X5'}
// query records
const cars = await db.query('Car', {
brand: 'BMW'
})
// cars = [{id: car1Id, brand: 'BMW', model: 'X5'}, {id: car2Id, brand: 'BMW', model: 'X6'}]
// count records
const count = await db.count('Car', {
brand: 'BMW'
})
// count = 2
// update record
await db.update(
'Car',
{ id: car1Id },
{
brand: 'BMW',
model: 'X5M'
}
)
// ensure record
await db.ensure('Car', ['brand'], {
brand: 'BMW',
model: 'X5C'
})
// will not insert record if brand is 'BMW' already exists
// modify record
await db.modify('Car', ['brand'], {
brand: 'BMW',
model: 'X5C'
})
// will update record model if brand is 'BMW' already exists
// delete record
await db.delete('Car', { id: car1Id })
// close connection
await db.commit()
// rollback
await db.rollback()
// close connection
await db.release()
// destroy client when server should be shutdown
await client.destroy()
// query records with options
const cars = await db.select(
'Car',
{
brand: 'BMW'
},
{
term: 'X5',
termRange: ['model'],
top: 10,
skip: 0
}
)
you can add index array to entity definition to create index on table, by default, it will create index on id field.
you can add join object to entity definition to create join on table. like below example, it will create userId field in Car entity.
import database from '@sumor/database'
const config = {
host: 'localhost',
user: 'root',
password: 'password',
database: 'database',
port: 3306
}
await database.install(config, {
entity: {
Car: {
property: {
brand: {
type: 'string',
length: 100
},
model: {
type: 'string',
length: 100
}
},
index: ['userId'],
join: {
user: 'User'
}
}
},
view: {}
})
FAQs
A database connector for MySQL, etc. Based on entity.
We found that @sumor/database demonstrated a not healthy version release cadence and project activity because the last version was released 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
/Security News
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.