parse-community / parse-community/parse-server

Add an overide for the increment function to allow user to specify siginificant digits

Open
#7,736 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:question
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Feature / Enhancement Checklist
Current Limitation

When using the parseObj.increment function, there is no way to account for floating point arithmatic errors. For example, if in the database I have a Quantity Column, and it has a value of 6.5 and I want to call `someObj.increment("Quantity", -4.1) instead of 2.4 being saved to that column 2.4000000000000004 is saved instead. From what I can tell there is no way to use the increment function and have it account for this. you have to do the math yourself and use set, which is not an option for us in thie case

Feature / Enhancement Description

make an override to the increment function that takes an additional parameter specifying the number of significant digits

Example Use Case

if in the database I have a Quantity Column, and it has a value of 6.5 and I want to call `someObj.increment("Quantity", -4.1) instead of 2.4 being saved to that column 2.4000000000000004 is saved instead. From what I can tell there is no way to use the increment function and have it account for this. you have to do the math yourself and use set, which is not an option for us in thie case

Alternatives / Workarounds

Using Set and the save would work, but given this column sees alot of traffic at once, it raises concerns of a race condition happening which can lead to an inacurate count which is why we use the increment function rather than set and save.

3rd Party References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the parseObj.increment entry point and the tests covering increment persistence. Define how the significant-digits parameter should behave for floating-point increments, then verify the result remains atomic and preserves the race-condition safety described in the issue; add or update tests showing 6.5 incremented by -4.1 produces the intended rounded value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.