Subj : Saving data in custom module
To : Sam Alexander
From : echicken
Date : Fri Mar 25 2022 04:32 pm
Re: Saving data in custom module
By: Sam Alexander to All on Fri Mar 25 2022 15:13:06
SA> I'm probably overlooking this in the docs, but if I'm building a custom
SA> module how can I save data back to the Synchronet database or elsewhere?
SA> I'm still really foggy in how Sync saves data to the file system. I'm
SA> playing with some ideas for custom modules which will need to save data
SA> back, just not sure how to do this.
There are a lot of different ways. Synchronet and its modules don't store all of their data in any one place following any one format.
The exec/load/userprops.js library lets you set per-user keys and values arbitrarily.
The built-in File class lets you do typical file IO stuff. It's documented in jsobjs.html* and there are many usage examples in exec/. Create your own file wherever you like and put whatever you want in it. You can use it with ini files and with JSON.parse/JSON.stringify if you like.
There's the JSON-DB service, which lets you share a JS object among multiple clients including remote BBSs. Has a subscription feature so it'll push real-time updates to clients.
The user, message, and file databases can all be interacted with from JS. See the User class, the MsgBase class, the FileBase class in jsobjs.html*.
*
https://synchro.net/docs/jsobjs.html
---
echicken
electronic chicken bbs - bbs.electronicchicken.com
---
� Synchronet � electronic chicken bbs - bbs.electronicchicken.com