Edit field values with "SQL Addon"

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

Andre_H
Posts: 415
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

Edit field values with "SQL Addon"

Post by Andre_H »

Hi there,

i try to correct some data with the "SQL Addon". if i set a playcounter with

Code: Select all

UPDATE [Songs] SET [PlayCounter]=9 WHERE [ID]=10409
the value seems to be updated correctly in the database

Code: Select all

SELECT ID, AlbumArtist, Songtitle, PlayCounter FROM [Songs] WHERE [ID]=10409
shows "9". But the GUI still shows the old value "0", and it will be reset to "old value" +1 after the next playthrough.

Guess i'm doing it wrong?
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
Ludek
Posts: 4945
Joined: Fri Mar 09, 2007 9:00 am

Re: Edit field values with "SQL Addon"

Post by Ludek »

I guess this happens because the track is already loaded in the memory and shown in the user interface?

The correct steps would be something like this:

Code: Select all

var list = app.db.getTracklist('SELECT * FROM Songs WHERE ID = 10409', -1);
list.whenLoaded().then(() => {
	listForEach(list, (item) => { 
		item.playCounter = 9;
	});
	list.commitAsync(); // saves the tracks to the database and tag
});

Andre_H
Posts: 415
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

Re: Edit field values with "SQL Addon"

Post by Andre_H »

Ludek wrote: Thu Jan 28, 2021 11:49 am I guess this happens because the track is already loaded in the memory and shown in the user interface?
That's it. If i restart MMW on the "Pos1"-Node, execute my SQL, and then select the artist, the updates are there.

Thank's a lot!

Great Addon, btw.

[solved]
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
Post Reply