I have a created a simple model using dynamoose and now I want to migrate it into postgresql using sequelize. I am acquainted with dynamodb and how hash keys and range keys are set in it but how do I accomplish the same in postgresql using sequelize? Below is my previous model using dynamoose and my effort to migrate it using sequelize, but I'm not sure what to do with the keys:
//dynamoose
var dynamoose = require("dynamoose");
var MessageRatingSchema = new dynamoose.Schema({
id: {
type: String,
index: {
global: true
}
},
chatId: {
type: String,
hashKey: true
},
ratingType: {
type: String,
enum: ["NEGATIVE", "POSITIVE", "NEUTRAL", "MIXED"],
rangeKey: true
},
rating: {
type: Number
}
});
module.exports = MessageRatingSchema;
Trying to migrate it using sequelize:
const Sequelize = require("sequelize");
const sequelize = new Sequelize('PGDATABASE', 'PGUSER', 'PGPASS', {
host: 'localhost',
dialect: 'postgres'
});
const MessageRating = sequelize.define('MessageRating', {
id: {
type: Sequelize.STRING,
primaryKey: true
},
chatId: {
type: Sequelize.STRING
//hashkey
},
ratingType: {
type: Sequelize.STRING,
enum: ["NEGATIVE", "POSITIVE", "NEUTRAL", "MIXED"]
//sortkey
},
rating:{
type: Sequelize.NUMBER
}
}, {
// options
});
module.exports = MessageRating;
Please let me know if it is the right way and how can I set the corresponding hashKeys and rangeKeys using sequelize. Thank you.