mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
Add library function to retrieve vessel information.
In the `keystore` table, we now store information for our own
vessel (usually, where the Dougal server is installed). This
is an access function to retrieve that information.
The info stored for the vessel looks like this:
```yaml
type: vessel
key: ego
data:
imo: 9631890
mmsi: 257419000
name: Havila Charisma
contacts:
-
name: HC OM
phone: tel:+47123456789
email: hc.om@magseisfairfield.com
organisations:
Havila Charisma:
read: true
write: true
edit: true
```
This commit is contained in:
23
lib/www/server/lib/db/vessel/index.js
Normal file
23
lib/www/server/lib/db/vessel/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { pool } = require('../connection');
|
||||
|
||||
/** Retrieve vessel info.
|
||||
*
|
||||
* @a vesselID The ID of the target vessel. Defaults to `ego`
|
||||
* which is this server's parent vessel.
|
||||
*/
|
||||
async function info (vesselID = "ego") {
|
||||
|
||||
const text = `
|
||||
SELECT *
|
||||
FROM keystore
|
||||
WHERE type = 'vessel' AND key = $1;
|
||||
`;
|
||||
|
||||
const res = await pool.query(text, [ vesselID ]);
|
||||
return res.rows[0]?.data ?? {};
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
info
|
||||
};
|
||||
Reference in New Issue
Block a user