-
November 5th, 2020, 23:30 #1
- Join Date
- Jan 2020
- Posts
- 222
Help me locate and delete nodes...
I'm iterating through database entries that I've created trying to delete them and I must be doing something wrong. Here is my code and the database:
Code:for k, v in pairs(ztWindowRecordList.getChildren()) do if (DB.getValue(v, "windowNodePath") == sWindowNodePath) and (DB.getValue(v, "windowClass") == cWindowClass) then DB.deleteChild(v, k); end end
and
Code:<DM_ZTabber> <ztabber_window_list> <id-00001> <windowClass type="string">masterindex</windowClass> <windowNodePath type="string">tables</windowNodePath> </id-00001> <id-00002> <windowClass type="string">table</windowClass> <windowNodePath type="string">tables.id-00001</windowNodePath> </id-00002> </ztabber_window_list> </DM_ZTabber>
The database looks exactly how I want it. What I want to do is now delete, say, the entry with id-0002 if the data in "windowClass" and "windowNodePath" match some variable information in my script (sWindowNodePath and cWindowClass).
I'm pretty sure I'm doing something wrong because the data never gets deleted from the DB.
Thanks.
-
November 6th, 2020, 00:01 #2
make sure you hit /save after doing it - fg runs from an in memory DB and writes to disk every 5 mins
is the code right? i dont know
-
November 6th, 2020, 00:02 #3
- Join Date
- Jan 2020
- Posts
- 222
-
November 6th, 2020, 00:17 #4
- Join Date
- Jan 2020
- Posts
- 222
Duh.
I was doing it wrong.
Here's the corrected code for future reference:
Code:for k, v in pairs(ztWindowRecordList.getChildren()) do if (DB.getValue(v, "windowNodePath") == sWindowNodePath) and (DB.getValue(v, "windowClass") == cWindowClass) then DB.deleteChild(ztWindowRecordList, k); end end
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks