@nina-protocol/nina-db 0.0.119 → 0.0.120

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,20 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.table('posts_releases', table => {
7
+ table.string('created_at').nullable();
8
+ table.string('updated_at').nullable();
9
+ });
10
+ };
11
+ /**
12
+ * @param { import("knex").Knex } knex
13
+ * @returns { Promise<void> }
14
+ */
15
+ export const down = function (knex) {
16
+ return knex.schema.table('posts_releases', table => {
17
+ table.dropColumn('created_at');
18
+ table.dropColumn('updated_at');
19
+ });
20
+ };
@@ -23,7 +23,8 @@ class Post extends Model {
23
23
  },
24
24
  };
25
25
  }
26
- async format() {
26
+ async format(options = {}) {
27
+ const { includeBlocks = true } = options;
27
28
  const publisher = await this.$relatedQuery('publisher').select('publicKey');
28
29
  const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
29
30
  this.publisher = publisher.publicKey;
@@ -36,6 +37,10 @@ class Post extends Model {
36
37
  delete this.publisherId;
37
38
  delete this.id;
38
39
  delete this.hubId;
40
+ // Strip blocks for list views unless explicitly requested
41
+ if (!includeBlocks && this.data?.blocks) {
42
+ delete this.data.blocks;
43
+ }
39
44
  stripHtmlIfNeeded(this.data, 'body');
40
45
  }
41
46
  static relationMappings = () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.119",
3
+ "version": "0.0.120",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function(knex) {
6
+ return knex.schema.table('posts_releases', table => {
7
+ table.string('created_at').nullable();
8
+ table.string('updated_at').nullable();
9
+ });
10
+ };
11
+
12
+ /**
13
+ * @param { import("knex").Knex } knex
14
+ * @returns { Promise<void> }
15
+ */
16
+ export const down = function(knex) {
17
+ return knex.schema.table('posts_releases', table => {
18
+ table.dropColumn('created_at');
19
+ table.dropColumn('updated_at');
20
+ });
21
+ };
@@ -25,7 +25,9 @@ class Post extends Model {
25
25
  };
26
26
  }
27
27
 
28
- async format() {
28
+ async format(options = {}) {
29
+ const { includeBlocks = true } = options;
30
+
29
31
  const publisher = await this.$relatedQuery('publisher').select('publicKey');
30
32
  const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
31
33
 
@@ -36,11 +38,16 @@ class Post extends Model {
36
38
  delete this.hub.id;
37
39
  delete this.hub.authorityId;
38
40
  }
39
-
41
+
40
42
  delete this.publisherId
41
43
  delete this.id
42
44
  delete this.hubId
43
-
45
+
46
+ // Strip blocks for list views unless explicitly requested
47
+ if (!includeBlocks && this.data?.blocks) {
48
+ delete this.data.blocks;
49
+ }
50
+
44
51
  stripHtmlIfNeeded(this.data, 'body');
45
52
  }
46
53