Hello @anon79585656 ,
We have Java Longs as ids. (which is sometimes to big for JS).
When doing a search in the main search field of this collection the error occurs on our forest agent (server side)
Database Table
create table subscription
(
id bigint not null
constraint subscription_pkey
primary key,
version bigint not null,
date_created timestamp not null,
end_date timestamp not null,
last_updated timestamp not null,
note varchar(255),
object_id varchar(255) not null,
product_id bigint not null
constraint fk1456591d9c2000c2
references product,
quantity integer,
renewal_type varchar(255) not null,
share_it_purchase_item_id bigint
constraint fk1456591d2390c009
references purchase_item,
start_date timestamp not null
);
Model
const { decryptWithFixedSalt, encryptWithFixedSalt } = require('../services/encrypted-fields');
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Subscription = sequelize.define(
'subscription',
{
version: {
type: DataTypes.BIGINT,
allowNull: false,
},
dateCreated: {
type: DataTypes.DATE,
allowNull: false,
},
endDate: {
type: DataTypes.DATE,
allowNull: false,
},
lastUpdated: {
type: DataTypes.DATE,
allowNull: false,
},
note: {
type: DataTypes.STRING,
get() {
return decryptWithFixedSalt(this.getDataValue('note'));
},
set(value) {
return this.setDataValue('note', encryptWithFixedSalt(value));
},
},
objectId: {
type: DataTypes.STRING,
allowNull: false,
},
quantity: {
type: DataTypes.INTEGER,
},
renewalType: {
type: DataTypes.STRING,
allowNull: false,
},
startDate: {
type: DataTypes.DATE,
allowNull: false,
},
},
{
tableName: 'subscription',
underscored: true,
timestamps: false,
schema: process.env.DATABASE_SCHEMA,
}
);
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Subscription.associate = (models) => {
Subscription.belongsTo(models.purchaseItem, {
foreignKey: {
name: 'shareItPurchaseItemIdKey',
field: 'share_it_purchase_item_id',
},
as: 'shareItPurchaseItem',
});
Subscription.belongsTo(models.product, {
foreignKey: {
name: 'productIdKey',
field: 'product_id',
},
as: 'product',
});
Subscription.hasMany(models.license, {
foreignKey: {
name: 'subscriptionIdKey',
field: 'subscription_id',
},
as: 'licenses',
});
Subscription.hasMany(models.productKey, {
foreignKey: {
name: 'subscriptionIdKey',
field: 'subscription_id',
},
as: 'productKeys',
});
};
return Subscription;
};
Note: The encrypted getter/setter is the only change I did.
Forest-Environment-Id: 68385
Forest-Project-Id: 54928
Forest-Rendering-Id: 82745
Forest-Team-Id: 54359