@nina-protocol/nina-db 0.0.89 → 0.0.90

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,18 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.table('subscriptions', table => {
7
+ table.string('ref').nullable();
8
+ });
9
+ };
10
+ /**
11
+ * @param { import("knex").Knex } knex
12
+ * @returns { Promise<void> }
13
+ */
14
+ export const down = function (knex) {
15
+ return knex.schema.table('subscriptions', table => {
16
+ table.dropColumn('ref');
17
+ });
18
+ };
@@ -8,8 +8,8 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
- import { customAlphabet } from 'nanoid';
12
11
  import promiseRetry from 'promise-retry';
12
+ import { customAlphabet } from 'nanoid';
13
13
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
14
14
  const randomStringGenerator = customAlphabet(alphabet, 12);
15
15
  export default class Release extends Model {
@@ -13,7 +13,6 @@ class Subscription extends Model {
13
13
  type: 'object',
14
14
  required: ['datetime'],
15
15
  properties: {
16
- publicKey: { type: 'string' },
17
16
  datetime: { type: 'string' },
18
17
  from: { type: 'string' },
19
18
  to: { type: 'string' },
@@ -24,7 +23,7 @@ class Subscription extends Model {
24
23
  },
25
24
  };
26
25
  }
27
- static async findOrCreate({ publicKey, from, to, datetime, subscriptionType }) {
26
+ static async findOrCreate({ from, to, datetime, subscriptionType }) {
28
27
  let subscription = await Subscription.query().findOne({ from, to });
29
28
  if (subscription) {
30
29
  return subscription;
@@ -32,7 +31,7 @@ class Subscription extends Model {
32
31
  subscription = await Subscription.query().insert({
33
32
  from, to, datetime, subscriptionType
34
33
  });
35
- console.log('Inserted subscription: ', publicKey);
34
+ console.log('Inserted subscription: ', from, to);
36
35
  return subscription;
37
36
  }
38
37
  async format() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function(knex) {
6
+ return knex.schema.table('subscriptions', table => {
7
+ table.string('ref').nullable();
8
+ });
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('subscriptions', table => {
17
+ table.dropColumn('ref');
18
+ });
19
+ };
@@ -8,12 +8,12 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
+ import promiseRetry from 'promise-retry';
11
12
  import { customAlphabet } from 'nanoid';
12
13
  import promiseRetry from 'promise-retry';
13
14
 
14
15
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
15
16
  const randomStringGenerator = customAlphabet(alphabet, 12);
16
-
17
17
  export default class Release extends Model {
18
18
  static tableName = 'releases';
19
19
 
@@ -49,7 +49,7 @@ export default class Release extends Model {
49
49
  archived: { type: 'boolean' },
50
50
  },
51
51
  }
52
-
52
+
53
53
  static findOrCreate = async (publicKey, hubPublicKey=null) => {
54
54
  try {
55
55
  let release = await Release.query().findOne({ publicKey });
@@ -14,7 +14,6 @@ class Subscription extends Model {
14
14
  type: 'object',
15
15
  required: ['datetime'],
16
16
  properties: {
17
- publicKey: { type: 'string' },
18
17
  datetime: { type: 'string' },
19
18
  from: { type: 'string' },
20
19
  to: { type: 'string' },
@@ -26,7 +25,7 @@ class Subscription extends Model {
26
25
  };
27
26
  }
28
27
 
29
- static async findOrCreate({publicKey, from, to, datetime, subscriptionType}) {
28
+ static async findOrCreate({from, to, datetime, subscriptionType}) {
30
29
  let subscription = await Subscription.query().findOne({ from, to });
31
30
  if (subscription) {
32
31
  return subscription;
@@ -35,7 +34,7 @@ class Subscription extends Model {
35
34
  subscription = await Subscription.query().insert({
36
35
  from, to, datetime, subscriptionType
37
36
  });
38
- console.log('Inserted subscription: ', publicKey)
37
+ console.log('Inserted subscription: ', from, to)
39
38
  return subscription;
40
39
  }
41
40