@nina-protocol/nina-db 0.0.119 → 0.0.121
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
|
+
};
|
package/dist/models/Post.js
CHANGED
|
@@ -23,10 +23,13 @@ class Post extends Model {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
async format() {
|
|
27
|
-
const
|
|
26
|
+
async format(options = {}) {
|
|
27
|
+
const { includeBlocks = true } = options;
|
|
28
|
+
const publisher = await this.$relatedQuery('publisher');
|
|
28
29
|
const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
|
|
30
|
+
await publisher.format();
|
|
29
31
|
this.publisher = publisher.publicKey;
|
|
32
|
+
this.publisherAccount = publisher;
|
|
30
33
|
if (publishedThroughHub) {
|
|
31
34
|
this.publishedThroughHub = publishedThroughHub.publicKey;
|
|
32
35
|
this.hub = publishedThroughHub;
|
|
@@ -36,6 +39,10 @@ class Post extends Model {
|
|
|
36
39
|
delete this.publisherId;
|
|
37
40
|
delete this.id;
|
|
38
41
|
delete this.hubId;
|
|
42
|
+
// Strip blocks for list views unless explicitly requested
|
|
43
|
+
if (!includeBlocks && this.data?.blocks) {
|
|
44
|
+
delete this.data.blocks;
|
|
45
|
+
}
|
|
39
46
|
stripHtmlIfNeeded(this.data, 'body');
|
|
40
47
|
}
|
|
41
48
|
static relationMappings = () => ({
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|
package/src/models/Post.js
CHANGED
|
@@ -25,22 +25,31 @@ class Post extends Model {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async format() {
|
|
29
|
-
const
|
|
28
|
+
async format(options = {}) {
|
|
29
|
+
const { includeBlocks = true } = options;
|
|
30
|
+
|
|
31
|
+
const publisher = await this.$relatedQuery('publisher');
|
|
30
32
|
const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
|
|
31
33
|
|
|
34
|
+
await publisher.format();
|
|
32
35
|
this.publisher = publisher.publicKey;
|
|
36
|
+
this.publisherAccount = publisher;
|
|
33
37
|
if (publishedThroughHub) {
|
|
34
38
|
this.publishedThroughHub = publishedThroughHub.publicKey;
|
|
35
39
|
this.hub = publishedThroughHub;
|
|
36
40
|
delete this.hub.id;
|
|
37
41
|
delete this.hub.authorityId;
|
|
38
42
|
}
|
|
39
|
-
|
|
43
|
+
|
|
40
44
|
delete this.publisherId
|
|
41
45
|
delete this.id
|
|
42
46
|
delete this.hubId
|
|
43
|
-
|
|
47
|
+
|
|
48
|
+
// Strip blocks for list views unless explicitly requested
|
|
49
|
+
if (!includeBlocks && this.data?.blocks) {
|
|
50
|
+
delete this.data.blocks;
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
stripHtmlIfNeeded(this.data, 'body');
|
|
45
54
|
}
|
|
46
55
|
|