@nina-protocol/nina-db 0.0.77 → 0.0.79

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.alterTable('subscriptions', table => {
7
+ table.string('publicKey').nullable().alter();
8
+ });
9
+ };
10
+ /**
11
+ * @param { import("knex").Knex } knex
12
+ * @returns { Promise<void> }
13
+ */
14
+ export const down = function (knex) {
15
+ return knex.schema.alterTable('subscriptions', table => {
16
+ table.string('publicKey').notNullable().alter();
17
+ });
18
+ };
@@ -11,7 +11,7 @@ class Subscription extends Model {
11
11
  static get jsonSchema() {
12
12
  return {
13
13
  type: 'object',
14
- required: ['publicKey', 'datetime'],
14
+ required: ['datetime'],
15
15
  properties: {
16
16
  publicKey: { type: 'string' },
17
17
  datetime: { type: 'string' },
@@ -24,15 +24,15 @@ class Subscription extends Model {
24
24
  },
25
25
  };
26
26
  }
27
- static async findOrCreate({ publicKey, from, to, datetime, subscriptionType }) {
28
- let subscription = await Subscription.query().findOne({ publicKey });
27
+ static async findOrCreate({ from, to, datetime, subscriptionType }) {
28
+ let subscription = await Subscription.query().findOne({ from, to });
29
29
  if (subscription) {
30
30
  return subscription;
31
31
  }
32
32
  subscription = await Subscription.query().insert({
33
- publicKey, from, to, datetime, subscriptionType
33
+ from, to, datetime, subscriptionType
34
34
  });
35
- console.log('Inserted subscription: ', publicKey);
35
+ console.log('Inserted subscription: ', from, to);
36
36
  return subscription;
37
37
  }
38
38
  async format() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
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.alterTable('subscriptions', table => {
7
+ table.string('publicKey').nullable().alter();
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.alterTable('subscriptions', table => {
17
+ table.string('publicKey').notNullable().alter();
18
+ });
19
+ };
@@ -12,7 +12,7 @@ class Subscription extends Model {
12
12
  static get jsonSchema() {
13
13
  return {
14
14
  type: 'object',
15
- required: ['publicKey', 'datetime'],
15
+ required: ['datetime'],
16
16
  properties: {
17
17
  publicKey: { type: 'string' },
18
18
  datetime: { type: 'string' },
@@ -26,16 +26,16 @@ class Subscription extends Model {
26
26
  };
27
27
  }
28
28
 
29
- static async findOrCreate({publicKey, from, to, datetime, subscriptionType}) {
30
- let subscription = await Subscription.query().findOne({ publicKey });
29
+ static async findOrCreate({from, to, datetime, subscriptionType}) {
30
+ let subscription = await Subscription.query().findOne({ from, to });
31
31
  if (subscription) {
32
32
  return subscription;
33
33
  }
34
34
 
35
35
  subscription = await Subscription.query().insert({
36
- publicKey, from, to, datetime, subscriptionType
36
+ from, to, datetime, subscriptionType
37
37
  });
38
- console.log('Inserted subscription: ', publicKey)
38
+ console.log('Inserted subscription: ', from, to)
39
39
  return subscription;
40
40
  }
41
41