Commit f6e2d256794d075ec47526344d41a008b5a814bd
Merge branch 'rmRelatedmessages'
Dominic Tarr committed on 8/10/2018, 6:33:44 AMParent: a6a68e420db6fa2dc9bc79f5c8babc18c0308799
Parent: fdc7aa8c33b9639e96b202b3cbe202350b53bcc5
Files changed
api.md | changed |
index.js | changed |
lib/validators.js | changed |
api.md | ||
---|---|---|
@@ -198,46 +198,8 @@ | ||
198 | 198 | - `keys` (boolean, default: `true`): whether the `data` event should contain keys. If set to `true` and `values` set to `false` then `data` events will simply be keys, rather than objects with a `key` property. |
199 | 199 | - `values` (boolean, default: `true`): whether the `data` event should contain values. If set to `true` and `keys` set to `false` then `data` events will simply be values, rather than objects with a `value` property. |
200 | 200 | |
201 | 201 | |
202 | - | |
203 | -## relatedMessages: async | |
204 | - | |
205 | -Retrieve the tree of messages related to the given id. | |
206 | - | |
207 | -```bash | |
208 | -relatedMessages --id {msgid} [--rel value] [--count] [--parent] | |
209 | -``` | |
210 | - | |
211 | -```js | |
212 | -relatedMessages ({ id:, rel:, count:, parent: }, cb) | |
213 | -``` | |
214 | - | |
215 | -This is ideal for collecting things like threaded replies. | |
216 | -The output is a recursive structure like this: | |
217 | - | |
218 | -``` js | |
219 | -{ | |
220 | - key: <id>, | |
221 | - value: <msg>, | |
222 | - related: [ | |
223 | - <recursive>,... | |
224 | - ], | |
225 | - //number of messages below this point. (when opts.count = true) | |
226 | - count: <int>, | |
227 | - //the message this message links to. this will not appear on the bottom level. | |
228 | - //(when opts.parent = true) | |
229 | - parent: <parent_id> | |
230 | -} | |
231 | -``` | |
232 | - | |
233 | - - `id` (MsgID): Root message, fetches messages related message to its ID. | |
234 | - - `rel` (string, optional): Filters the links by the relation string. | |
235 | - - `count` (boolean, default: `false`): Include a `count` of each message's decendant messages. | |
236 | - - `parent` (boolean, default: `false`): Include the `parent` id of each message. | |
237 | - | |
238 | - | |
239 | - | |
240 | 202 | ## add: async |
241 | 203 | |
242 | 204 | Add a well-formed message to the database. |
243 | 205 |
index.js | ||
---|---|---|
@@ -122,9 +122,8 @@ | ||
122 | 122 | getLatest : valid.async(ssb.getLatest, 'feedId'), |
123 | 123 | latestSequence : valid.async(ssb.latestSequence, 'feedId'), |
124 | 124 | createFeed : ssb.createFeed, |
125 | 125 | whoami : function () { return { id: feed.id } }, |
126 | - relatedMessages : valid.async(ssb.relatedMessages, 'relatedMessagesOpts'), | |
127 | 126 | query : ssb.query, |
128 | 127 | createFeedStream : valid.source(ssb.createFeedStream, 'readStreamOpts?'), |
129 | 128 | createHistoryStream : valid.source(ssb.createHistoryStream, ['createHistoryStreamOpts'], ['feedId', 'number?', 'boolean?']), |
130 | 129 | createLogStream : valid.source(ssb.createLogStream, 'readStreamOpts?'), |
lib/validators.js | ||
---|---|---|
@@ -185,30 +185,8 @@ | ||
185 | 185 | if (v.values && typeof v.values != 'boolean' && typeof v.values != 'number') |
186 | 186 | return AttrType(n, 'values', 'boolean') |
187 | 187 | }, |
188 | 188 | |
189 | - relatedMessagesOpts: function (v, n) { | |
190 | - var err = this.get('object')(v, n) | |
191 | - if (err) | |
192 | - return err | |
193 | - | |
194 | - // .id | |
195 | - if (!ref.isMsg(v.id)) | |
196 | - return MissingAttr(n, 'id', 'msgId') | |
197 | - | |
198 | - // .rel | |
199 | - if (v.rel && typeof v.rel != 'string') | |
200 | - return AttrType(n, 'rel', 'string') | |
201 | - | |
202 | - // .count | |
203 | - if (v.count && typeof v.count != 'boolean' && typeof v.count != 'number') | |
204 | - return AttrType(n, 'count', 'boolean') | |
205 | - | |
206 | - // .parent | |
207 | - if (v.parent && typeof v.parent != 'boolean' && typeof v.parent != 'number') | |
208 | - return AttrType(n, 'parent', 'boolean') | |
209 | - }, | |
210 | - | |
211 | 189 | isBlockedOpts: function (v, n) { |
212 | 190 | var err = this.get('object')(v, n) |
213 | 191 | if (err) |
214 | 192 | return err |
Built with git-ssb-web