My sails application works well while connected to mysql database. I however had the need to switch to mongoDB as it is a requirement for the project and here comes the issues I face.
My models have some relationships for it to work and to achieve this, I had to make some modifications which include the following: I used uuid to set the primary keys (id) for each model (The id was automatically generated by mysql before). When I however try to submit requests to the server I experience the error:
AdapterError: Unexpected error from database adapter: Invalid primary key value provided for `id`. Cannot interpret `9456b206-ebcf-4a6d-b81c-93964c027f04` as a Mongo id.
(Usually, this is the result of a bug in application logic.)
Here is a sample of one of my models - picked.js:
module.exports = {
attributes: {
userId: {
type: 'string',
required: true,
//unique: true,
},
comment:{
type: 'string',
required: true
},
createdBy:{
type: 'string',
required: true
},
info: {
model: 'personalinfo'
},
admin: {
model: 'admin'
},
id:{
type: 'string',
},
},
};