
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
nestjs-mindsdb
Advanced tools
A NestJS module for integrating with MindsDB. This allows for easy model management and prediction within your NestJS application.
A NestJS module for integrating with MindsDB. This allows for easy model management and prediction within your NestJS application.
npm install nestjs-mindsdb
Models in MindsDB are described through the IModel
interface. Here's how you can define your models:
import { Granularity, IModel } from "./mindsdb.models";
export const Models = new Map<string, IModel>([
[
"balance_auto",
{
name: "balance_auto",
granularity: Granularity.day,
targetColumn: "sum",
predictOptions: {
join: "views.enriched_balance",
where: ["t.customerId = $CUSTOMER_ID$", "t.date > $DATE$"],
},
trainingOptions: {
select: "select * from enriched_balance",
groupBy: "customerId",
orderBy: "date",
horizon: 60,
window: 90,
// using: {
// submodels: [{ module: 'GluonTSMixer', args: {} }],
// },
},
finetuneOptions: {
select: "select * from enriched_balance where customerId = $CUSTOMER_ID$ and date > $DATE$",
integration: undefined,
},
},
],
[
"balance_gluon",
{
name: "balance_gluon",
granularity: Granularity.day,
targetColumn: "sum",
view: {
select: "select * from production.banking.enriched_balance",
name: "balance_gluon_enriched_balance",
},
predictOptions: {
join: "views.enriched_balance",
where: ["t.customerId = $CUSTOMER_ID$", "t.date > $DATE$"],
},
trainingOptions: {
select: "select * from balance_gluon_enriched_balance",
groupBy: "customerId",
orderBy: "date",
horizon: 60,
window: 90,
// using: {
// submodels: [{ module: 'GluonTSMixer', args: {} }],
// },
},
finetuneOptions: {
select: "select * from balance_gluon_enriched_balance",
integration: undefined,
},
},
],
]);
Placeholders such as $CUSTOMER_ID$
and $DATE$
can be used in the model definition. These will be replaced when you're making predictions.
To expose your models through a RESTful API, extend the AbstractMindsdbController
and use NestJS's @Controller
decorator. This controller will automatically have all the endpoints corresponding to the methods in the AbstractMindsdbController
.
import { Controller } from '@nestjs/common';
import { MindsdbService } from 'nestjs-mindsdb';
import { AbstractMindsdbController } from 'nestjs-mindsdb';
@Controller('mindsdb')
export class MindsdbController extends AbstractMindsdbController {
constructor(mindsdbService: MindsdbService) {
super(mindsdbService);
}
}
The MindsdbService
provides several methods that correspond to different operations you can perform on your models.
If parameters are not provided will use the one's defined on the IModel object for each.
const createDto = new CreateMindsdbDto();
createDto.name = 'balance_auto';
mindsdbService.create(createDto);
const predictDto = new PredictMindsdbDto();
predictDto.join = "views.enriched_balance";
predictDto.where = ["t.customerId = $CUSTOMER_ID$", "t.date > $DATE$"];
predictDto.limit = 100;
predictDto.params = {
$CUSTOMER_ID$: 1234,
$DATE$: new Date('2023-01-01')
};
mindsdbService.predict('balance_auto', predictDto);
const finetuneDto = new FinetuneMindsdbDto();
finetuneDto.select = "select * from enriched_balance where customerId = $CUSTOMER_ID$ and date > $DATE$";
finetuneDto.params = {
$CUSTOMER_ID$: 1234,
$DATE$: new Date('2023-01-01')
};
mindsdbService.finetune('balance_auto', finetuneDto);
const retrainDto = new RetrainMindsDbDto();
retrainDto.select = "select * from balance_gluon_enriched_balance";
retrainDto.groupBy = "customerId";
retrainDto.orderBy = "date";
retrainDto.window = 90;
retrainDto.horizon = 60;
mindsdbService.retrain('balance_auto', retrainDto);
const allModels = mindsdbService.findAll();
mindsdbService.findOne('balance_auto');
mindsdbService.remove('balance_auto');
Remember to adjust any paths, references, and examples according to your project structure and requirements.
To utilize MindsDB within your NestJS application, you have to set up the module. Given the nature of this module being dynamic, configurations are essential for its proper functioning. Here's a basic setup:
import { MindsdbModule } from 'nestjs-mindsdb';
import { Models } from './path-to-your-models-definition';
@Module({
imports: [MindsdbModule.forRoot(Models)],
})
export class AppModule {}
FAQs
A NestJS module for integrating with MindsDB. This allows for easy model management and prediction within your NestJS application.
The npm package nestjs-mindsdb receives a total of 0 weekly downloads. As such, nestjs-mindsdb popularity was classified as not popular.
We found that nestjs-mindsdb 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.