Code Monkey home page Code Monkey logo

Comments (10)

rjrodger avatar rjrodger commented on July 21, 2024

merge is the correct behavior - so nosql stores like level will need to do a load first

this is often no desired, so all stores should support a "merge" option in their settings:
merge:true means merge data
merge:false means override data

also allow merge$ parameter in individual operations for custom behaviour
{id$:x,merge$:false,...}

from seneca-store-test.

paolochiodi avatar paolochiodi commented on July 21, 2024

just to clarify: the merge option defaults to true?

from seneca-store-test.

rjrodger avatar rjrodger commented on July 21, 2024

yes

from seneca-store-test.

paolochiodi avatar paolochiodi commented on July 21, 2024

@rjrodger another quick clarification: should the object returned after the save already be the merged one or just a copy of the params passed in to the save?

from seneca-store-test.

rjrodger avatar rjrodger commented on July 21, 2024

the merged one - we always want to result to be as update to date as possible

from seneca-store-test.

paolochiodi avatar paolochiodi commented on July 21, 2024

@rjrodger I'm fixing seneca-mem-store to make it follow new tests, but I just noticed that seneca itself doesn't send to the store attributes starting or ending with $ on save, except from id$.

Do you want me to provide a PR to seneca or do you want to change your decision on this?

from seneca-store-test.

rjrodger avatar rjrodger commented on July 21, 2024

$ attributes are special - reserved for use by seneca, so are never persisted

from seneca-store-test.

paolochiodi avatar paolochiodi commented on July 21, 2024

@rjrodger sorry, I wasn't clear in my comment.

In your initial response to this issue you introduced the merge$ option for an individual save operation, however at the moment seneca strips all the attributes starting or ending with $ and thus merge$ doesn't reach the store that is in that way unable to implement the correct behaviour.

We may want to "not introduce" the merge$ option on individual option or amend seneca to not strip $ attributes and leave that to the store (or just allow the merge$ option to pass through).

Which one do you prefer?

Please note that the latter would be a breaking change since current stores that don't follow this rule may end up storing the $ attributes.

from seneca-store-test.

rjrodger avatar rjrodger commented on July 21, 2024

We'll add merge$ as an individual option - and accept the pass through problem, as it is relatively harmless.

In general this also raises the question of what a store should do with attributed it does not recognise.
So two new rules for stores:

  1. never store $ attributes (existing stores will need to be updated, but not urgent)
  2. ignore attributes you don't know about (applies to SQL stores mostly - mongodb will just store it anyway)

from seneca-store-test.

paolochiodi avatar paolochiodi commented on July 21, 2024

@rjrodger About $ attributes: if I understand correctly they are already filtered by seneca itself except for id$ (hence the need for https://github.com/senecajs/seneca/pull/217/files, now merged)

from seneca-store-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.