couchset 0.2.0 → 0.2.1

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.
@@ -35,20 +35,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
42
  exports.createUpdate = void 0;
40
- var lodash_1 = require("../utils/lodash");
43
+ var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
44
+ var pickBy_1 = __importDefault(require("lodash/pickBy"));
45
+ var identity_1 = __importDefault(require("lodash/identity"));
41
46
  var createUpdate = function (args) { return __awaiter(void 0, void 0, void 0, function () {
42
47
  var model, id, data, createdItem, error_1;
43
48
  return __generator(this, function (_a) {
44
49
  switch (_a.label) {
45
50
  case 0:
46
51
  model = args.model, id = args.id;
47
- data = args.data;
52
+ data = (0, pickBy_1.default)(args.data, identity_1.default);
48
53
  _a.label = 1;
49
54
  case 1:
50
55
  _a.trys.push([1, 5, , 6]);
51
- if (!!(0, lodash_1.isEmpty)(id)) return [3 /*break*/, 3];
56
+ if (!!(0, isEmpty_1.default)(id)) return [3 /*break*/, 3];
52
57
  // update
53
58
  return [4 /*yield*/, model.updateById(id, data)];
54
59
  case 2:
@@ -1 +1 @@
1
- {"version":3,"file":"common.model.js","sourceRoot":"","sources":["../../src/shared/common.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAwC;AAUjC,IAAM,YAAY,GAAG,UAAU,IAAkB;;;;;gBAC7C,KAAK,GAAQ,IAAI,MAAZ,EAAE,EAAE,GAAI,IAAI,GAAR,CAAS;gBACnB,IAAI,GAAQ,IAAI,CAAC,IAAI,CAAC;;;;qBAGpB,CAAC,IAAA,gBAAO,EAAC,EAAE,CAAC,EAAZ,wBAAY;gBACZ,SAAS;gBACT,qBAAM,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,EAAA;;gBADhC,SAAS;gBACT,SAAgC,CAAC;gBACjC,sBAAO,IAAI,EAAC;oBAGI,qBAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAA;;gBAAtC,WAAW,GAAG,SAAwB;gBAC5C,sBAAO,WAAW,EAAC;;;gBAEnB,OAAO,CAAC,KAAK,CAAC,6BAAsB,KAAK,CAAC,cAAc,CAAE,EAAE,OAAK,CAAC,CAAC;gBACnE,sBAAO,IAAI,EAAC;;;;KAEnB,CAAC;AAjBW,QAAA,YAAY,gBAiBvB","sourcesContent":["import {isEmpty} from '../utils/lodash';\nimport {Model} from '../model';\n\ninterface CreateUpdate {\n model: Model;\n id?: string;\n owner?: string;\n data: any;\n}\n\nexport const createUpdate = async <T>(args: CreateUpdate): Promise<T | null> => {\n const {model, id} = args;\n const data: any = args.data;\n\n try {\n if (!isEmpty(id)) {\n // update\n await model.updateById(id, data);\n return data;\n }\n // create\n const createdItem = await model.create(data);\n return createdItem;\n } catch (error) {\n console.error(`error creating for ${model.collectionName}`, error);\n return null;\n }\n};\n"]}
1
+ {"version":3,"file":"common.model.js","sourceRoot":"","sources":["../../src/shared/common.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAqC;AACrC,yDAAmC;AACnC,6DAAuC;AAWhC,IAAM,YAAY,GAAG,UAAU,IAAkB;;;;;gBAC7C,KAAK,GAAQ,IAAI,MAAZ,EAAE,EAAE,GAAI,IAAI,GAAR,CAAS;gBACnB,IAAI,GAAQ,IAAA,gBAAM,EAAC,IAAI,CAAC,IAAI,EAAE,kBAAQ,CAAC,CAAC;;;;qBAGtC,CAAC,IAAA,iBAAO,EAAC,EAAE,CAAC,EAAZ,wBAAY;gBACZ,SAAS;gBACT,qBAAM,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,EAAA;;gBADhC,SAAS;gBACT,SAAgC,CAAC;gBACjC,sBAAO,IAAI,EAAC;oBAGI,qBAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAA;;gBAAtC,WAAW,GAAG,SAAwB;gBAC5C,sBAAO,WAAW,EAAC;;;gBAEnB,OAAO,CAAC,KAAK,CAAC,6BAAsB,KAAK,CAAC,cAAc,CAAE,EAAE,OAAK,CAAC,CAAC;gBACnE,sBAAO,IAAI,EAAC;;;;KAEnB,CAAC;AAjBW,QAAA,YAAY,gBAiBvB","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport pickBy from 'lodash/pickBy';\nimport identity from 'lodash/identity';\n\nimport {Model} from '../model';\n\ninterface CreateUpdate {\n model: Model;\n id?: string;\n owner?: string;\n data: any;\n}\n\nexport const createUpdate = async <T>(args: CreateUpdate): Promise<T | null> => {\n const {model, id} = args;\n const data: any = pickBy(args.data, identity);\n\n try {\n if (!isEmpty(id)) {\n // update\n await model.updateById(id, data);\n return data;\n }\n // create\n const createdItem = await model.create(data);\n return createdItem;\n } catch (error) {\n console.error(`error creating for ${model.collectionName}`, error);\n return null;\n }\n};\n"]}
@@ -3,4 +3,3 @@ export * from './text.utils';
3
3
  export * from './utils.schema';
4
4
  export * from './awaitTo';
5
5
  export * from './log';
6
- export * from './lodash';
@@ -19,5 +19,4 @@ __exportStar(require("./text.utils"), exports);
19
19
  __exportStar(require("./utils.schema"), exports);
20
20
  __exportStar(require("./awaitTo"), exports);
21
21
  __exportStar(require("./log"), exports);
22
- __exportStar(require("./lodash"), exports);
23
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB;AACtB,2CAAyB","sourcesContent":["export * from './date';\nexport * from './text.utils';\nexport * from './utils.schema';\nexport * from './awaitTo';\nexport * from './log';\nexport * from './lodash';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB","sourcesContent":["export * from './date';\nexport * from './text.utils';\nexport * from './utils.schema';\nexport * from './awaitTo';\nexport * from './log';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "couchset",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Couchbase ORM",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -29,9 +29,6 @@
29
29
  "pre-commit": "lint-staged"
30
30
  }
31
31
  },
32
- "engines": {
33
- "node": ">=4.2.0"
34
- },
35
32
  "repository": {
36
33
  "type": "git",
37
34
  "url": "git+https://github.com/couchset/couchset.git"
@@ -65,7 +62,7 @@
65
62
  "@types/couchbase": "^2.4.9",
66
63
  "@types/debug": "^4.1.7",
67
64
  "@types/express": "^4.17.13",
68
- "@types/lodash": "^4.14.168",
65
+ "@types/lodash": "^4.17.10",
69
66
  "@types/mocha": "^8.2.0",
70
67
  "@types/node": "^10.0.3",
71
68
  "@types/source-map-support": "^0.4.0",
@@ -88,8 +85,9 @@
88
85
  "reflect-metadata": "^0.1.13",
89
86
  "rimraf": "^2.5.4",
90
87
  "ts-node": "^9.1.1",
91
- "tslint": "^5.11.0",
92
- "tslint-config-standard": "^8.0.1",
88
+ "tslint": "^6.1.3",
89
+ "tslint-config-standard": "^9.0.0",
90
+ "tsx": "^4.19.1",
93
91
  "typescript": "^4.4.3"
94
92
  },
95
93
  "peerDependencies": {
@@ -99,6 +97,7 @@
99
97
  "couchbase": "^4.4.2",
100
98
  "couchbase-serverless": "^0.0.2",
101
99
  "debug": "^4.3.1",
100
+ "lodash": "^4.17.21",
102
101
  "uuid": "^8.3.2"
103
102
  }
104
103
  }
@@ -1 +0,0 @@
1
- export declare function isEmpty(value?: unknown): boolean;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmpty = void 0;
4
- function isEmpty(value) {
5
- if (value == null) {
6
- return true;
7
- }
8
- if (Array.isArray(value) || typeof value === 'string') {
9
- return value.length === 0;
10
- }
11
- if (value instanceof Map || value instanceof Set) {
12
- return value.size === 0;
13
- }
14
- if (typeof value === 'object') {
15
- return Object.keys(value).length === 0;
16
- }
17
- return false;
18
- }
19
- exports.isEmpty = isEmpty;
20
- //# sourceMappingURL=lodash.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lodash.js","sourceRoot":"","sources":["../../src/utils/lodash.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,KAAe;IACnC,IAAI,KAAK,IAAI,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACf;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACnD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;KAC7B;IAED,IAAI,KAAK,YAAY,GAAG,IAAI,KAAK,YAAY,GAAG,EAAE;QAC9C,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;KAC1C;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAlBD,0BAkBC","sourcesContent":["export function isEmpty(value?: unknown): boolean {\n if (value == null) {\n return true;\n }\n\n if (Array.isArray(value) || typeof value === 'string') {\n return value.length === 0;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\n"]}