@indra.ai/deva.data 0.0.124 → 0.0.125

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.
Files changed (2) hide show
  1. package/index.js +9 -9
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -84,20 +84,22 @@ const DATA = new Deva({
84
84
  describe: the insert function that inserts into the specified collection.
85
85
  ***************/
86
86
  async insert(opts) {
87
+ this.belief('data', `uid:${opts.data.id.uid}`);
87
88
  this.action('func', `insert:${opts.collection}:${opts.data.id.uid}`);
88
89
  let result = false;
89
90
  try {
90
91
  this.state('insert', `${opts.collection}:${opts.data.id.uid}`);
91
- const {database} = this.data().personal.mongo;
92
-
93
92
  this.state('connect', `${opts.collection}:${opts.data.id.uid}`);
94
93
  await this.modules.client.connect(); // connect to the database client.
95
- const db = this.modules.client.db(database); // set the database to use
94
+ const db = this.modules.client.db(this.vars.database); // set the database to use
96
95
 
97
96
  result = await db.collection(opts.collection).insertOne(opts.data); // insert the data
98
97
  } finally {
99
98
  await this.modules.client.close(); // close the connection when done
100
99
  this.action('return', `insert:${opts.collection}:${opts.data.id.uid}`);
100
+ this.state('valid', `insert:${opts.collection}:${opts.data.id.uid}`);
101
+ this.intent('good', `insert:${opts.collection}:${opts.data.id.uid}`);
102
+ this.belief('vedic', `uid:${opts.data.id.uid}`);
101
103
  return result; // return the result to the requestor.
102
104
  }
103
105
  },
@@ -112,9 +114,8 @@ const DATA = new Deva({
112
114
  let result = false;
113
115
  try {
114
116
  this.state('update', opts.collection);
115
- const {database} = this.data().personal.mongo;
116
117
  await this.modules.client.connect(); // connect to the database client.
117
- const db = this.modules.client.db(database); // set the database to use
118
+ const db = this.modules.client.db(this.vars.database); // set the database to use
118
119
  result = await db.collection(opts.collection).updateOne(
119
120
  { _id: new ObjectId(`${opts.id}`) },
120
121
  { $set: opts.data }
@@ -136,9 +137,8 @@ const DATA = new Deva({
136
137
  let result = false;
137
138
  const {collection,data} = opts;
138
139
  try {
139
- const {database} = this.data().personal.mongo;
140
140
  await this.modules.client.connect();
141
- const db = this.modules.client.db(database);
141
+ const db = this.modules.client.db(this.vars.database);
142
142
  result = await db.collection(collection).find(data).sort({created:1}).toArray();
143
143
  } finally {
144
144
  await this.modules.client.close();
@@ -157,9 +157,8 @@ const DATA = new Deva({
157
157
  try {
158
158
  this.state('search', opts.text);
159
159
  const {collection,limit} = this.vars.search;
160
- const {database} = this.data().personal.mongo;
161
160
  await this.modules.client.connect();
162
- const db = this.modules.client.db(database);
161
+ const db = this.modules.client.db(this.vars.database);
163
162
  const table = db.collection(collection);
164
163
 
165
164
  // await table.dropIndex('a.text_1');
@@ -552,6 +551,7 @@ const DATA = new Deva({
552
551
  onReady(data, resolve) {
553
552
  const {VLA} = this.info();
554
553
  const {mongo} = this.data().global;
554
+ this.vars.database = mongo.database;
555
555
  this.modules.client = new MongoClient(mongo.uri);
556
556
  this.prompt(`${this.vars.messages.ready} > VLA:${VLA.uid}`);
557
557
  return resolve(data);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "65859204002504361305",
3
3
  "name": "@indra.ai/deva.data",
4
- "version": "0.0.124",
4
+ "version": "0.0.125",
5
5
  "license": "VLA:65859204002504361305 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "65859204002504361305",
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "homepage": "https://indra.ai",
58
58
  "dependencies": {
59
- "@indra.ai/deva": "^1.8.9",
59
+ "@indra.ai/deva": "^1.9.1",
60
60
  "mongodb": "^6.13.0"
61
61
  },
62
62
  "data": {