@lowdefy/connection-mongodb 4.0.0-rc.7 → 4.0.0-rc.9

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.
@@ -27,7 +27,7 @@ async function MongodbUpdateOne({ blockId , connection , pageId , request , requ
27
27
  const { value , ...responseWithoutValue } = await collection.findOneAndUpdate(filter, update, options);
28
28
  response = responseWithoutValue;
29
29
  const after = await collection.findOne({
30
- _id: value._id
30
+ _id: value ? value._id : response.lastErrorObject?.upserted
31
31
  });
32
32
  await logCollection.insertOne({
33
33
  args: {
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ObjectId } from 'mongodb';
16
- import { type } from '@lowdefy/helpers';
16
+ import { serializer, type } from '@lowdefy/helpers';
17
17
  function replacer(_, value) {
18
18
  if (type.isObject(value)) {
19
19
  Object.keys(value).forEach((key)=>{
@@ -23,12 +23,6 @@ function replacer(_, value) {
23
23
  _oid: value[key].toHexString()
24
24
  };
25
25
  }
26
- if (type.isDate(value[key])) {
27
- // eslint-disable-next-line no-param-reassign
28
- value[key] = {
29
- _date: value[key].valueOf()
30
- };
31
- }
32
26
  });
33
27
  return value;
34
28
  }
@@ -39,11 +33,6 @@ function replacer(_, value) {
39
33
  _oid: item.toHexString()
40
34
  };
41
35
  }
42
- if (type.isDate(item)) {
43
- return {
44
- _date: item.valueOf()
45
- };
46
- }
47
36
  return item;
48
37
  });
49
38
  }
@@ -54,20 +43,17 @@ function reviver(key, value) {
54
43
  if (value._oid) {
55
44
  return ObjectId.createFromHexString(value._oid);
56
45
  }
57
- if (type.isInt(value._date) || type.isString(value._date)) {
58
- return new Date(value._date);
59
- }
60
46
  }
61
47
  return value;
62
48
  }
63
49
  function serialize(obj) {
64
- if (type.isUndefined(obj)) return obj;
65
- return JSON.parse(JSON.stringify(obj, replacer));
50
+ return serializer.copy(obj, {
51
+ replacer
52
+ });
66
53
  }
67
- // need to use replacer here, since objects are already partially deserialised.
68
- // otherwise dates become strings
69
54
  function deserialize(obj) {
70
- if (type.isUndefined(obj)) return obj;
71
- return JSON.parse(JSON.stringify(obj, replacer), reviver);
55
+ return serializer.copy(obj, {
56
+ reviver
57
+ });
72
58
  }
73
59
  export { serialize, deserialize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/connection-mongodb",
3
- "version": "4.0.0-rc.7",
3
+ "version": "4.0.0-rc.9",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,13 +42,13 @@
42
42
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-rc.7",
45
+ "@lowdefy/helpers": "4.0.0-rc.9",
46
46
  "@next-auth/mongodb-adapter": "1.1.1",
47
47
  "mongodb": "4.13.0",
48
48
  "saslprep": "1.0.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@lowdefy/ajv": "4.0.0-rc.7",
51
+ "@lowdefy/ajv": "4.0.0-rc.9",
52
52
  "@shelf/jest-mongodb": "4.1.4",
53
53
  "@swc/cli": "0.1.59",
54
54
  "@swc/core": "1.3.24",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "0bbeceb0a73e7c8061d83829bb5066f08cacf094"
65
+ "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
66
66
  }