spice-js 2.5.29 → 2.5.31

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.
@@ -92,12 +92,6 @@ class SpiceModel {
92
92
  }
93
93
  };
94
94
  this.deleted = false;
95
- /*
96
- if (args.args) {
97
- delete args.args["ctx"];
98
- }
99
- */
100
-
101
95
  this[_database] = new Database(args.connection || "default", {
102
96
  collection: args.collection,
103
97
  scope: args.scope
@@ -209,8 +203,6 @@ class SpiceModel {
209
203
  data = Array.of(data);
210
204
  }
211
205
 
212
- console.log("DAta", data);
213
-
214
206
  if (_this[_ctx]) {
215
207
  var returned = yield new _this[_ctx].state.process_fields().process(_this[_ctx], data, _this.type);
216
208
  return returned;
@@ -981,6 +973,10 @@ class SpiceModel {
981
973
  return _asyncToGenerator(function* () {
982
974
  try {
983
975
  // run serializers
976
+ if (!path_to_be_removed) {
977
+ path_to_be_removed = [];
978
+ }
979
+
984
980
  if (_this14.shouldSerializerRun(args, type)) {
985
981
  for (var i of _this14[_serializers][type]["modifiers"]) {
986
982
  try {
@@ -52,6 +52,28 @@ class Storage {
52
52
  })();
53
53
  }
54
54
 
55
+ download(_ref2) {
56
+ var _this2 = this;
57
+
58
+ return _asyncToGenerator(function* () {
59
+ var {
60
+ file,
61
+ bucket,
62
+ options
63
+ } = _ref2;
64
+
65
+ if (options) {
66
+ _this2.driver_options = _lodash.default.merge(_this2.driver_options, options);
67
+ }
68
+
69
+ var driver = new _this2.Driver(_this2.driver_options);
70
+ return yield driver.download({
71
+ file,
72
+ bucket
73
+ });
74
+ })();
75
+ }
76
+
55
77
  }
56
78
 
57
79
  exports.default = Storage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.5.29",
3
+ "version": "2.5.31",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -77,12 +77,6 @@ export default class SpiceModel {
77
77
  };
78
78
 
79
79
  this.deleted = false;
80
-
81
- /*
82
- if (args.args) {
83
- delete args.args["ctx"];
84
- }
85
- */
86
80
  this[_database] = new Database(args.connection || "default", {
87
81
  collection: args.collection,
88
82
  scope: args.scope,
@@ -186,7 +180,6 @@ export default class SpiceModel {
186
180
  data = Array.of(data)
187
181
  }
188
182
 
189
- console.log("DAta", data)
190
183
  if (this[_ctx]) {
191
184
  let returned = await new this[_ctx].state.process_fields().process(this[_ctx], data, this.type);
192
185
  return returned;
@@ -878,7 +871,11 @@ export default class SpiceModel {
878
871
  async do_serialize(data, type, old_data, args, path_to_be_removed) {
879
872
  try {
880
873
  // run serializers
881
-
874
+
875
+ if(!path_to_be_removed){
876
+ path_to_be_removed =[]
877
+ }
878
+
882
879
  if (this.shouldSerializerRun(args, type)) {
883
880
  for (let i of this[_serializers][type]["modifiers"]) {
884
881
  try {
@@ -918,6 +915,7 @@ export default class SpiceModel {
918
915
 
919
916
  // apply cleaners
920
917
  if (type == "read") {
918
+
921
919
  let props_to_clean = ["deleted", "type", ...path_to_be_removed];
922
920
  for (let i in this.props) {
923
921
  if (this.props[i].hide) {
@@ -27,4 +27,15 @@ export default class Storage {
27
27
  : path,
28
28
  });
29
29
  }
30
+
31
+ async download({ file, bucket, options }) {
32
+ if (options) {
33
+ this.driver_options = _.merge(this.driver_options, options);
34
+ }
35
+ let driver = new this.Driver(this.driver_options);
36
+ return await driver.download({
37
+ file,
38
+ bucket,
39
+ });
40
+ }
30
41
  }