Comments (8)
I can't reproduce this error. Could you give more information on data stored in model?
from racer.
Ok, the data is following:
{"game": {
"id": "6a30efbc-741e-46ae-9c65-3b54272d58c9_new-recruit-v3",
"scenario": {
"11": ["hello"],
"name": "New Recruit",
"gameType": "new-recruit-v3",
"gameCategory": "v3",
"demoStrategyList": [
"random"
],
"roles": [
"Recruiter",
"Candidate"
],
"anonymousMode": true,
"xlsxDownload": true,
"scenarioName": "New Recruit",
"onlineType": "inClass",
"rolesMeta": {
"Recruiter": {
"alias": "role0"
},
"Candidate": {
"alias": "role1"
}
},
"id": "temp_6a30efbc-741e-46ae-9c65-3b54272d58c9_new-recruit-v3",
"_templateName": "Default",
"base": true,
"parentId": "a178fe18-51ae-44de-be7a-728476dbfe60"
}
}}
I think it's important to notice that forked versions of racer and derby.js are used:
racer https://github.com/dmapper/racer#sync-upstream4
derby https://github.com/dmapper/derby#sync-upstream7
from racer.
Avoid using numeric object keys with racer. While it's working on local docs (in upstream version), I believe ShareDB will reject them in remote docs.
from racer.
Yes I got that using numeric object keys is a bad idea, though it looks inconsistent that it works here model.setDiffDeep('_page.game.scenario.11', ['hello123'])
and writes the changes to DB without errors but doesn't work this way model.set('_page.game.scenario.11', ['hello123'])
. And it obviously will work in this case:
model.scope('_page.game.scenario').set
{
"name": "New Recruit",
"gameType": "new-recruit-v3"
"123":
[
"hello",
"world"
]
}
from racer.
Well, the reason this model.set('_page.game.scenario.11', ['hello123'])
doesn't work is that .11
makes racer interpret _page.game.scenario
as array and tries to set scenario[11]
to hello123
. Which obviously doesn't work because _page.game.scenario
is an object, hence the error. I don't know why setDiffDeep
behaves differently...
from racer.
And, btw, if it is an array, it will first resize the array to at least 11 and then write to array[11]
. So trying to set a property .123
will resize the array to 123. Not a good idea...
from racer.
@michael-brade thanks for the information. Yes, we have an object with numeric keys, suppose it was set as follows:
model.scope('_page.game.scenario').set
{
'name': 'New Recruit'
'gameType': 'new-recruit-v3'
'courses':
'11': ['hello']
'127': ['world']
'default': ['hola']
}
then if I try to do model.set('_page.game.scenario.courses.127’, ['hello123’])
it will throw but model.setDiffDeep(‘_page.game.scenario.courses.127, ['hello123’])
will let me write into DB without any errors. I found it inconsistent.
from racer.
Related Issues (20)
- Racer null document instead of deleting it HOT 7
- query.ref can hang the browser
- Working example of angularjs app working with racer... for awhile HOT 1
- Immediate events break derby since racer 0.6.0-alpha43 HOT 1
- How can I use app.model.channel with new [email protected] HOT 6
- Exception in a model event subscription causes subscriptions break HOT 1
- Error message "Mutation on uncreated remote document" HOT 2
- State of Derby/Racer HOT 5
- Native iOS/Android version of Derby/sharedb
- setDiffDeep creates unnecessary ops when updating to the same scalar value
- Calling `setDiffDeep` from different models can set duplicate data on a given document in a race condition HOT 1
- If `cb` is undefined, `childModel.add` inputs for `segment` and `value` are incorrect HOT 2
- when items are removed from chained lists/refs, events fire twice HOT 4
- Add ability to fetch only if the data is not loaded HOT 1
- Dead project? HOT 2
- [dev] Upgrade from expect.js to Chai HOT 1
- [dev] Update to use Github actions HOT 1
- _splitPath function currently prevents the use of URL's as document identifiers (or any identifiers with . in) HOT 7
- Modern examples HOT 5
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 racer.