diff --git a/README.md b/README.md index aafee89..d9505a1 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,15 @@ const task = await TaskModel.create({ const task = await TaskModel.findOne({ id: 'cbdabs-29232323-msasd'}); ``` +5. You can also use the underlying ORM model and instance methods + +```typescript +// create task +const filter = { }; +const countTasks = await TaskModel.model.countDocuments(filter); + +``` + ## 🫶 Projects using this package See the projects using this package in action. - [Fractal Js](https://github.com/fractalerp/fractal-js) diff --git a/active_record.ts b/active_record.ts index 4118051..15d8189 100755 --- a/active_record.ts +++ b/active_record.ts @@ -9,8 +9,6 @@ import { ActiveRecordError } from "./lib/active_record_error"; export class ActiveRecord implements ActiveRecordInterface { private nosqlActiveRecord!: NoSqlActiveRecord; private relationalActiveRecord!: RelationalActiveRecord; - - // TODO read database type from memory private databaseType = DatabaseType.NOSQL; constructor(modelName: string, schema: Record, databaseType = DatabaseType.NOSQL) { diff --git a/nosql/nosql_active_record.ts b/nosql/nosql_active_record.ts index 1e6aa3c..f3b4bae 100644 --- a/nosql/nosql_active_record.ts +++ b/nosql/nosql_active_record.ts @@ -10,7 +10,7 @@ import { NoSQLActiveRecordInterface } from "./nosql_active_record_interface"; import DatabaseManagementSystem from "./../database/dms"; export class NoSqlActiveRecord implements NoSQLActiveRecordInterface { - private model: Model; + public model: Model; private dbms: DatabaseManagementSystem = new DatabaseManagementSystem(); @@ -22,7 +22,7 @@ export class NoSqlActiveRecord implements NoSQLActiveRecordInterface { this.model = process.env.NODE_ENV !== "test" ? this.dbms.nosqlDB.database.model(modelName, new Schema(mongoSchema as any)) - : model(modelName, new Schema(mongoSchema as any)) // allow for + : model(modelName, new Schema(mongoSchema as any)) // allow for test } async find(query: any): Promise { diff --git a/package.json b/package.json index 20cd903..5553a0d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@fractalerp/active-record-js", "appName": "Active Record Js", - "version": "1.0.14", + "version": "1.0.16", "description": "Responsible for representing business data", "author": "Acellam Guy ", "keywords": [ diff --git a/relational/relational_active_record.ts b/relational/relational_active_record.ts index edf102b..9e1969a 100644 --- a/relational/relational_active_record.ts +++ b/relational/relational_active_record.ts @@ -5,7 +5,7 @@ import { RelationalActiveRecordInterface } from "./relational_active_record_inte export class RelationalActiveRecord implements RelationalActiveRecordInterface { private sequelize!: Sequelize; - private model: typeof Model; + public model: typeof Model; constructor(modelName: string, schema: Record) { // TODO get global sequilize instance from memory