Comments (8)
That may be the problem, but it should not be. It seems you are proposing that I just work around the problem.
To be clear, I'm not complaining about the return value of Model.updateOne.set(valuesToSet), as the return value/format is entirely up to the authors of Sails/Waterline. My complaint is that a call to Model.updateOne.set(valuesToSet) additionally manipulates the value of valuesToSet, which is entirely unexpected.
In other words, my parameter (i.e. valuesToSet) that I initialized to have value x, will have a value of not x when I call Model.updateOne.set(valuesToSet), which at a minimum is not documented, and additionally I would assert is a poor practice/functionality when the stated purpose of the function is to manipulate the database.
Why is this function also manipulating the input parameter? No reasonable person would expect this to happen unless explicitly documented. Moreover the parameter has nothing to do with Mongo itself and is an object I have created in my code which may later be reused. The parameter should not be manipulated by that function
from sails.
@thesaxonedone Yes!
I updated the .update()
and .updateOne()
docs with a note about this behavior
from sails.
@pineconesundae Thanks for the suggestion! We'll add notes about this behavior to those pages.
from sails.
@thesaxonedone Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
- look for a workaround. (Even if it's just temporary, sharing your solution can save someone else a lot of time and effort.)
- tell us why this issue is important to you and your team. What are you trying to accomplish? (Submissions with a little bit of human context tend to be easier to understand and faster to resolve.)
- make sure you've provided clear instructions on how to reproduce the bug from a clean install.
- double-check that you've provided all of the requested version and dependency information. (Some of this info might seem irrelevant at first, like which database adapter you're using, but we ask that you include it anyway. Oftentimes an issue is caused by a confluence of unexpected factors, and it can save everybody a ton of time to know all the details up front.)
- read the code of conduct.
- if appropriate, ask your business to sponsor your issue. (Open source is our passion, and our core maintainers volunteer many of their nights and weekends working on Sails. But you only get so many nights and weekends in life, and stuff gets done a lot faster when you can work on it during normal daylight hours.)
- let us know if you are using a 3rd party plugin; whether that's a database adapter, a non-standard view engine, or any other dependency maintained by someone other than our core team. (Besides the name of the 3rd party package, it helps to include the exact version you're using. If you're unsure, check out this list of all the core packages we maintain.)
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
from sails.
Hi @thesaxonedone, I think the problem here is that you are using the same attribute 'id' which is being used by sails as your mongo ObjectId under the column '_id'.
I recommend overriding the id attribute in your model and defining it as a string, instead of a Mongo Object Id, this way, Sails will not try to convert it to ObjectId anymore.
I don't think this is a framework issue though! Should we close this issue?
from sails.
Hi @thesaxonedone, this behavior is for performance reasons and is documented here: https://sailsjs.com/documentation/upgrading/to-v-1-0#?changes-to-waterline-criteria-usage
from sails.
fair enough. Can we get this added to the documentation on Models under the Reference or Concepts section?. It seems rather buried if its only in the "upgrade notes" and I feel it would've been nice to see/know this was done intentionally when reading about the ORM, or models more generically.
from sails.
@thesaxonedone @eashaw
I happened upon this issue while searching the waterline, sails-mysql, and finally sails repos for some open issue about the behavior I was seeing. I just wanted to note that the mutation also happens on .create()
and .createEach()
as well. This is implied in the "upgrade notes", but it would be good to have it documented on the .create()
and .createEach()
pages as well, since that was the first place I went to look for this behavior.
from sails.
Related Issues (20)
- Put the new Mongo Pool Size config in sails-mongo HOT 6
- Dead link in README HOT 2
- Using CRSF set to true returns forbidden as response on api calls HOT 2
- @sailshq/lodash is not patched for all historic lodash prototype pollution bugs HOT 2
- Latest @sailshq/lodash reports its version incorrectly HOT 2
- find method in sails.js model HOT 1
- only req.on("close") is working HOT 1
- This is the most disgusting framework I've ever used! HOT 2
- This is the most disgusting framework I've ever used! HOT 2
- This is the most disgusting framework I've ever used! HOT 2
- Integrate search feature for mobile in sails documentation HOT 4
- Typo issue in customToJSON docs HOT 4
- README.md contains YouTube Thumbnail Is Misleading HOT 1
- Avoiding usage of sails-disk HOT 1
- Inactive Gitter channel for help HOT 3
- srv support in the connection url for sails-mongo HOT 7
- Error for sails-mysql with .fetch() HOT 1
- MariaDB support in documentation? HOT 3
- NPM audit issues in Sails HOT 5
- Can't connect mysql8.4 because mysql8.4 no longer supports the mysql_native_password plugin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sails.