new API getFeedID()

This commit is contained in:
Andre Staltz 2023-10-19 17:36:56 +03:00
parent b08f9baee9
commit 0937f3e8c6
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 15 additions and 0 deletions

View File

@ -405,6 +405,18 @@ function initRecord(peer, config) {
return record
}
/**
* @public
* @param {string} subdomain
* @returns {string}
*/
function getFeedID(subdomain) {
if (!accountID) throw new Error('Cannot getFeedID() before loading')
assertDBPlugin(peer)
const domain = fromSubdomain(subdomain)
return MsgV3.getMootID(accountID, domain)
}
/**
* @public
* @param {Msg} msg
@ -517,6 +529,7 @@ function initRecord(peer, config) {
load,
update,
read,
getFeedID,
isRoot,
isGhostable,
getFieldRoots,

View File

@ -143,6 +143,8 @@ test('Record isGhostable', (t) => {
const moot = MsgV3.createMoot(aliceID, 'record_v1__profile', aliceKeypair)
const mootID = MsgV3.getMsgID(moot)
assert.equal(mootID, peer.record.getFeedID('profile'), 'getFeedID')
const tangle = peer.db.getTangle(mootID)
const msgIDs = tangle.topoSort()