@mongoosejs/studio 0.0.41 → 0.0.42

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.
@@ -25,8 +25,15 @@ module.exports = ({ db }) => async function updateDocument(params) {
25
25
  throw new Error(`Model ${model} not found`);
26
26
  }
27
27
 
28
+ let processedUpdate = update;
29
+ if (Object.keys(update).length > 0) {
30
+ processedUpdate = Object.fromEntries(
31
+ Object.entries(update).map(([key, value]) => [key, value === 'null' ? null : value === 'undefined' ? undefined : value])
32
+ );
33
+ }
34
+
28
35
  const doc = await Model.
29
- findByIdAndUpdate(_id, update, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true });
36
+ findByIdAndUpdate(_id, processedUpdate, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true, runValidators: false });
30
37
 
31
38
  return { doc };
32
39
  };
@@ -970,6 +970,24 @@ module.exports = app => app.component('edit-date', {
970
970
  data: () => ({
971
971
  inputType: ''
972
972
  }),
973
+ methods: {
974
+ updateFromISO($event) {
975
+ const value = $event.target.value;
976
+ if (value == null) {
977
+ return this.$emit('input', $event.target.value);
978
+ }
979
+ if (value === 'null') {
980
+ return this.$emit('input', null);
981
+ }
982
+ if (value === 'undefined') {
983
+ return this.$emit('input', undefined);
984
+ }
985
+ const valueAsDate = new Date(value);
986
+ if (!isNaN(valueAsDate.valueOf())) {
987
+ this.$emit('input', $event.target.value);
988
+ }
989
+ }
990
+ },
973
991
  computed: {
974
992
  valueAsLocalString() {
975
993
  if (this.value == null) {
@@ -990,7 +1008,7 @@ module.exports = app => app.component('edit-date', {
990
1008
  },
991
1009
  valueAsISOString() {
992
1010
  if (this.value == null) {
993
- return this.value;
1011
+ return '' + this.value;
994
1012
  }
995
1013
  const date = new Date(this.value);
996
1014
  return date.toISOString();
@@ -2680,7 +2698,7 @@ module.exports = "<div class=\"edit-array\">\n <textarea\n ref=\"arrayEditor
2680
2698
  /***/ ((module) => {
2681
2699
 
2682
2700
  "use strict";
2683
- module.exports = "<div>\n <input v-if=\"dateSelection == 'picker'\" class=\"w-64 h-8 border border-gray-300 outline-0\" type=\"datetime-local\" :value=\"valueAsLocalString\" @input=\"$emit('input', $event.target.value)\">\n <input v-if=\"dateSelection == 'iso'\" type=\"text\" class=\"w-64 h-8 border border-gray-300 outline-0\" :value=\"valueAsISOString\" @input=\"$emit('input', $event.target.value)\">\n</div>";
2701
+ module.exports = "<div>\n <input\n v-if=\"dateSelection == 'picker'\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n type=\"datetime-local\"\n :value=\"valueAsLocalString\"\n @input=\"$emit('input', $event.target.value)\">\n <input\n v-if=\"dateSelection == 'iso'\"\n type=\"text\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n :value=\"valueAsISOString\"\n @input=\"updateFromISO\">\n</div>";
2684
2702
 
2685
2703
  /***/ }),
2686
2704