
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@pubsweet/base-model
Advanced tools
For persistence of data, PubSweet uses `@pubsweet/base-model` and its BaseModel class, which is a basic model based on [Objection.js](https://vincit.github.io/objection.js/).
For persistence of data, PubSweet uses @pubsweet/base-model and its BaseModel class, which is a basic model based on Objection.js.
For a data model component, its defined exports are:
module.exports = {
typeDefs: // GraphQL type definitions
resolvers: // GraphQL resolvers
modelName: 'Collection',
model: require('./collection'),
}
Migrations (folder ./migrations) are automatically added if they exist. For example migrations, see e.g. the User model's migrations.
If you use @pubsweet/model-some-model in your app (by specifying it as a component in the configuration), typeDefs and resolvers are gathered in server's schema.js to compose the app's entire GraphQL schema from three parts: 1. pubsweet-server, 2. app's components and 3. app's config.
To use the above models, all you need to do is to add them to the pubsweet.components configuration, e.g.:
pubsweet: {
components: ['@pubsweet/model-some-model'],
},
The data model's migrations will be added to the list of your app's migrations, and GraphQL queries and mutations will automatically be added to your API.
There are a few methods in the BaseModel that add utility features.
const manuscript = await new Manuscript({ title: 'Test' }).save()
const manuscript = await new Manuscript({
title: 'Test',
teams: [{ role: 'reviewer' }],
}).saveGraph()
Passes parameters onwards to Objection's findById and supports its options:
const manuscript = await Manuscript.find(
'b70cd527-6b96-4612-b516-38a0e5ebfa65',
{ eager: 'teams' },
)
Passes parameters to Objection's where.
const manuscript = await Manuscript.findByField(
'title',
'Breakthrough research',
)
Uses Objections's where().limit(1).
const manuscript = await Manuscript.findOneByField('content', 'Great success')
const manuscript = await Manuscript.all()
Shown in (https://gitlab.coko.foundation/pubsweet/pubsweet/blob/master/packages/base-model/test/extended-data-model-component/src/index.js) is an extended data model (extended-data-model-component) for testing purposes. It exports the following things:
module.exports = {
typeDefs:
resolvers:
modelName: 'Model',
model: require('./model'),
extending: '@pubsweet/model-some-model',
}
Things are exactly the same as in the non-extended data model, but there is one big difference, the extending property. This is a string, the name of the model that this extended data model extends. In this case @pubsweet/model-extended-some-model extends @pubsweet/model-some-model and what this means, in practice, is that @pubsweet/model-some-model's GraphQL schema, resolvers and migration paths will be added to @pubsweet/model-extended-some-model's. This happens recursively, so for example if you had a @pubsweet/model-super-extended-some-model that extended @pubsweet/model-extended-some-model, it would also include @pubsweet/model-some-models's GraphQL schema, resolvers and migration paths. ∞
Take a look at the micropubs/wormbase application, for an example implementation of two models, Manuscript and Review using the BaseModel class, the supplied GraphQL connectors and Authsome.
FAQs
For persistence of data, PubSweet uses `@pubsweet/base-model` and its BaseModel class, which is a basic model based on [Objection.js](https://vincit.github.io/objection.js/).
The npm package @pubsweet/base-model receives a total of 176 weekly downloads. As such, @pubsweet/base-model popularity was classified as not popular.
We found that @pubsweet/base-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.