Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@fractalerp/active-record-js
Advanced tools
A library responsible for representing business data.
This library follows the Active Record Pattern
by building a wrapper on top of popular orm such as Mongoose and Sequelize to support all kinds of databases
RDBMS_DATABASE_URI="mysql://DATBASE_USER:DATABASE_PASSWORD@DATABASE_HOST:DATABASE_PORT/DATABASE_DB"
NOSQL_DATABASE_URI="mongodb://DATABASE_HOST:DATABASE_PORT/DATABASE_DB"
NOSQL_DATABASE_ADAPTER="mongodb"
SchemaProperty
. See example belowimport { ActiveRecord } from "@fractalerp/active-record-js"
export interface ITaskModelDocument {
name: string;
description: string;
}
const TaskModelSchema = {
name: {
type: String,
required: true,
unique: true
},
description: {
type: String,
default: null
}
};
export const TaskModel = new ActiveRecord<ITaskModelDocument>("Task", TaskModelSchema);
Method | Description |
---|---|
find | returns list of data objects |
findOne | returns one data item |
create | save item to the data store |
update | updates the record in the store |
delete | delete item from the data store |
Since we support all kinds of databases. The following are the respective methods of the two kinds of databases.
This only applies to NOSQL databases
Method | Description |
---|---|
aggregate | peform aggregate action based on a pipeline |
index | create an index in the document store |
This only applies to Relational databases
Method | Description |
---|---|
query | create a raw SQL to send to database |
beginTransaction | start a transaction |
commitTransaction | persist a transaction |
rollbackTransaction | rollback a transaction |
Other than that, all the other ORM respective methods for Sequelize
and Mongoose
are supported by default.
// create task
const task = await TaskModel.create({
name: 'Use fractalerp active record js',
description: 'Change all models'
});
// Find one task
const task = await TaskModel.findOne({ id: 'cbdabs-29232323-msasd'});
// create task
const filter = { };
const countTasks = await TaskModel.model.countDocuments(filter);
See the projects using this package in action.
We are actively maintaining this boilerplate, please report any issues or suggestion for improvement at https://github.com/fractalerp/active-record-js/issues
Prerequisite: Install git, node package manager, webpack CLI, grunt CLI
To contribute, fork and clone.
> git clone https://github.com/fractalerp/active-record-js.git
The code is in typescript. Use a typescript IDE of your choice, like Visual Studio Code or WebStorm.
To set up the development environment, run:
> npm install
To automatically compile, bundle and push code changes to the running test project, run:
> npm start
To run the project unit tests with code coverage, results can be found at dist/testresults/coverage/index.html
, run:
> npm run test:unit
Run the unit test continuously during development:
> npm run test:dev
While developing, you will probably rely mostly on npm start
; however, there are additional scripts at your disposal:
npm run <script> | Description |
---|---|
start | Build the project and monitor source and config for changes and rebuild. Start the dev server |
watch | Build the project and monitor source and config for changes and rebuild. |
emit | Output javascript code |
test | Runs lint, build, unit tests with mocha and generates a coverage report |
test:dev | Runs mocha and watches for changes to re-run tests; does not generate coverage reports. |
test:unit | Runs unit tests with mocha and generates a coverage report. |
build:prod | Build app optimized for production |
build:dev | Build app optimized for debugging. |
lint | Lint all .js files. |
lint:fix | Lint and fix all .ts files. |
FAQs
Responsible for representing business data
The npm package @fractalerp/active-record-js receives a total of 26 weekly downloads. As such, @fractalerp/active-record-js popularity was classified as not popular.
We found that @fractalerp/active-record-js 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.