@nina-protocol/nina-db 0.0.71 → 0.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.table('releases', table => {
7
+ table.boolean('hidden').notNullable().defaultTo(false);
8
+ });
9
+ };
10
+ /**
11
+ * @param { import("knex").Knex } knex
12
+ * @returns { Promise<void> }
13
+ */
14
+ export const down = function (knex) {
15
+ };
@@ -4,6 +4,7 @@ import Hub from './Hub.js';
4
4
  import Post from './Post.js';
5
5
  import Release from './Release.js';
6
6
  import Verification from './Verification.js';
7
+ import Subscription from './Subscription.js';
7
8
  export default class Account extends Model {
8
9
  static tableName = 'accounts';
9
10
  static idColumn = 'id';
@@ -36,6 +37,8 @@ export default class Account extends Model {
36
37
  this.verifications = verifications;
37
38
  }
38
39
  delete this.id;
40
+ const followers = await Subscription.query().where('to', this.publicKey).range(0, 0);
41
+ this.followers = followers.total;
39
42
  };
40
43
  static relationMappings = () => ({
41
44
  published: {
@@ -3,6 +3,7 @@ import { stripHtmlIfNeeded } from '../utils/index.js';
3
3
  import Account from './Account.js';
4
4
  import Release from './Release.js';
5
5
  import Post from './Post.js';
6
+ import Subscription from './Subscription.js';
6
7
  export default class Hub extends Model {
7
8
  static get tableName() {
8
9
  return 'hubs';
@@ -30,6 +31,8 @@ export default class Hub extends Model {
30
31
  delete this.authorityId;
31
32
  delete this.id;
32
33
  stripHtmlIfNeeded(this.data, 'description');
34
+ const followers = await Subscription.query().where('to', this.publicKey).range(0, 0);
35
+ this.followers = followers.total;
33
36
  }
34
37
  static relationMappings = () => ({
35
38
  authority: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -4,6 +4,7 @@ import Hub from './Hub.js';
4
4
  import Post from './Post.js';
5
5
  import Release from './Release.js';
6
6
  import Verification from './Verification.js';
7
+ import Subscription from './Subscription.js';
7
8
 
8
9
  export default class Account extends Model {
9
10
  static tableName= 'accounts';
@@ -41,6 +42,8 @@ export default class Account extends Model {
41
42
  this.verifications = verifications;
42
43
  }
43
44
  delete this.id
45
+ const followers = await Subscription.query().where('to', this.publicKey).range(0,0);
46
+ this.followers = followers.total;
44
47
  }
45
48
 
46
49
  static relationMappings = () => ({
package/src/models/Hub.js CHANGED
@@ -3,6 +3,7 @@ import { stripHtmlIfNeeded } from '../utils/index.js';
3
3
  import Account from './Account.js';
4
4
  import Release from './Release.js';
5
5
  import Post from './Post.js';
6
+ import Subscription from './Subscription.js';
6
7
 
7
8
  export default class Hub extends Model {
8
9
  static get tableName() {
@@ -33,6 +34,9 @@ export default class Hub extends Model {
33
34
  delete this.id;
34
35
 
35
36
  stripHtmlIfNeeded(this.data, 'description');
37
+
38
+ const followers = await Subscription.query().where('to', this.publicKey).range(0, 0);
39
+ this.followers = followers.total;
36
40
  }
37
41
 
38
42
  static relationMappings = () => ({