Using a different ORM
Using Mongoose (for MongoDB)
For using Mongoose as the ORM, please do the following steps:
- Create a file with name exactly as
orm-model-config.cjs
in the root directory(same level of package.json) - In this file, insert the following lines:
class Model{ static ormKey = 'mongoose'; } module.exports = Model;
- Pwoli is now ready for Mongoose!
- Click here to learn more about using Mongoose with Pwoli.
Using an ORM other than Sequelize or Mongoose
If you are using a different ORM other than Sequelize or Mongoose (like DynamoDB), you can use it with Pwoli by carrying out the following steps:
- Implement an ORMAdapter which should implement the interface IORMAdapter - Just like SequelizeAdapter or MongooseAdapter
- Create a file with name exactly as
orm-model-config.cjs
in the root directory(same level of package.json) - In this file, insert the following lines:
//like sequelize.Model for Sequelize, mongoose.Model for Mongoose.. const BaseModel = require('<path-to-base-model-class-of-the-orm>'); module.exports = BaseModel;
- In your application’s entry script(index.js or index.ts), just after importing
Pwoli
, place the following lines(Here, assuming that the ORM used is DynamoDB):import { Application as Pwoli } from 'pwoli'; import MyDynamoDBAdapter from '<path-to-MyDynamoDBAdapter>'; Pwoli.ormAdapterClasses['dynamodb'] = MyDynamoDBAdapter; // Pwoli.setORMAdapter(new Pwoli.ormAdapterClasses['dynamodb']());
- You’re done! Pwoli is ready to use DynamoDB as the ORM for all it’s Components and Widgets. Likewise, this same procedure can be done for any ORM out there.