Update refernce not reflex immediately
apppro123 opened this issue · comments
How do i update a refrence?
name= "CalendarEvent";
props={
Title: title,
Calendar: "#Calendar1",
...}
name: "Calendar1",
props: {
Title: "string",
Color: "string",
}
Do i now update the Calendar in CalenderEvent with CalendarEvent.update({Calendar: CalendarObject}) or with CalendarEvent.update({Calendar_id: newCalendarId})??
And if i want to change the calendar can i just say Calendar1.update(idOfCalendar, {Title: newTitle})
and it then also takes the updated calendar in CalendarEvent or do i also have to update CalendarEvent for Calendar?
Thank you
Hi @apppro123,
-
You should be able to update by calling
update({ Calendar: (new CalendarObject) })
.P/s: Thanks for mention about this, I find out the
Calendar_id
has not been updated immediately. This is a bug and I'll update soon. -
You're right. If you want update only a property of a reference (Calendar1), you only need to update the Calendar1 as you described, and it should reflex in CalendarEvent
I have pushed an update (v 0.2.95) that fix this issue. Reinstall and clear cache to apply changes.
Let me know if you still have trouble updating the reference.
You should be able to update by calling update({ Calendar: (new CalendarObject) })
after insert new CalendarObject
I will close this issue since it has been resolved. Also, feel free to reopen or create a new one again
My app crashes when i insert an event with an alarm object (refrence to event) and then want to update the alarm of this event.
console.error: "uncaught at rootSaga", "at rootSaga
at rootSaga
at takeEvery
at changeCalendarEvent
TypeError: Cannot read property 'indexOf' of undefined
at blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:125672:35
at Array.forEach ()
at Document.update (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:125669:29)
at changeSingleEvent$ (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:117179:65)
at tryCatch (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21610:19)
at Generator.invoke [as _invoke] (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21785:24)
at Generator.prototype.(anonymous function) [as next] (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21653:23)
at tryCatch (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21610:19)
at invoke (blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21686:22)
at blob:http://localhost:8081/40e09586-0f72-45ff-9840-90d5da4ca5bb:21716:13"
Document.update
...\node_modules\vasern\vasern\src\core\vasern\Document.js:218:23
changeSingleEvent$
let newAlarm = await Alarm.update(a.id, {Date: a.Date, NotificatinId: a.NotficationId});
console.log(newAlarm);
It crashes after Alarm.update(), so id doesnt show console.log(newAlarm) anymore!
Look like a property name didn't exist in the schema. I guess you want to use NotificationId
instead of NotificatinId
? So the update code look like
Alarm.update(a.id, {Date: a.Date, NotificationId: a.NotficationId})
Thank you so much, these little typos ...
No worries Noah!
I should/will add a better error message when input are invalid
I have just noticed, that the if i for example have Calendar_id in my event object and i want to change the refrence (different calendar) and i update event object with Calendar Calendar_id persists and doesnt changes.
Is it possible that there is still a bug in the code?
Hi @apppro123, it's hard to say. In that case, the ID will first be stored in in-memory storage, and then make an async request to persist changes to disk.
Can you post a snippet code? I can use the code and try to debug it
It has been resolved thank you!
Great, let me know in case the issue still persist
I know have the problem that vasern doesnt update the properties _id. For example if i have the property Alarm and i update Alarm to null or [] empty array Alarm_id still has the old array with ids. (And i tried to update Alarm_id itself but then i throws the issue that Alarm_id doesnt exists...).
And i also have found the issue that if i update, in my case an event, which has multiple refrences i have to pass the refrences (in the update object) otherwise the refrences are set to null.
Thank you for your work!
Hi @apppro123, I understand the first issue with the _id
and will make an improvement within a few days.
I haven't fully understood the second issue, can you give me a short example? Much appreciated
name = "CalendarEvent";
props = {
Title: "string",
Notes: "string",
Calendar: "#Calendar1"
}
if i want to update CalendarEvent with CalendarEvent.update(id, {Title: "hello"});
it deletes/sets Calendar to null/undefined, so i have to pass Calendar-object, too, even if it doesnt change (like thta: CalendarEvent.update(id, {Title: "hello", Calendar: oldCalendar});). Then everything works. But I just have to pass refrences like that, with other elements it works (in this case Notes would be fine).
Thank you!
Thank you for the example and further explanation.
I understand it now. I'll work on this problem soon.