balderdashy / balderdashy/sails

How can not-defined attributes(arbitrary data) be allowed?

Open
#7,249 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Node version**: 16.16.0
**Sails version** _(sails)_: 1.5.2
**ORM hook version** _(sails-hook-orm)_: 4.0.1
**Sockets hook version** _(sails-hook-sockets)_: 2.0.1
**Organics hook version** _(sails-hook-organics)_: Not used
**Grunt hook version** _(sails-hook-grunt)_: 5.0.0
**Uploads hook version** _(sails-hook-uploads)_: Not used
**DB adapter & version** _(e.g. sails-mysql@5.55.5)_: Not used
**Skipper adapter & version** _(e.g. skipper-s3@5.55.5)_: Not used


Hi.
I'm using MongoDB and sails-mongo v2.0.0.

According to https://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?schema, not-defined attribute(arbitrary data) can be allowed if `config.models.schema` is set to false.
But, I failed to do that with the below message when creating a record to a model:
```
WARNING: Automatically trimmed extraneous values!
In call to addMyModel(), 1 of the provided values (notDefinedAttribute) does not correspond with any recognized input.
Please try again without the extra value, or check your usage and adjust accordingly.
```

In addition, controllers also remove not-defined attributes when it is called thru routes.

How can I allow it?

Contributor guide

Open the contributing guide

Research direction

Start with the documented config.models.schema setting and reproduce the warning from addMyModel() using an undefined attribute. Then trace the controller path when the model is called through routes. Done means identifying why the attribute is trimmed and documenting or verifying the configuration needed to preserve it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.