Skip to content

Commit c2eef9f

Browse files
committed
Fix Database update for MongoDB and Record Update for MongoDB
1 parent ef244f1 commit c2eef9f

File tree

10 files changed

+91
-77
lines changed

10 files changed

+91
-77
lines changed

publishable/assets/js/app.js

+57-53
Original file line numberDiff line numberDiff line change
@@ -5470,7 +5470,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
54705470
data: formData,
54715471
responseType: 'json'
54725472
}).then(function (res) {
5473-
// console.log(res.data);
5473+
console.log(res.data);
5474+
54745475
if (res.data.success == true) {
54755476
toastr.success("Record Added successfully.");
54765477

@@ -5483,7 +5484,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
54835484
_this.$Progress.finish();
54845485
}
54855486
})["catch"](function (err) {
5486-
// console.log(err.response);
5487+
console.log(err.response);
5488+
54875489
_this.$Progress.fail();
54885490

54895491
_this.displayError(err.response);
@@ -5504,7 +5506,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
55045506
data: formData,
55055507
responseType: 'json'
55065508
}).then(function (res) {
5507-
// console.log(res.data);
5509+
console.log(res.data);
5510+
55085511
if (res.data.success == true) {
55095512
toastr.success("Record Updated successfully.");
55105513

@@ -5517,7 +5520,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
55175520
_this2.$Progress.finish();
55185521
}
55195522
})["catch"](function (err) {
5520-
// console.log(err.response);
5523+
console.log(err.response);
5524+
55215525
_this2.$Progress.fail();
55225526

55235527
_this2.displayError(err.response);
@@ -10628,7 +10632,8 @@ __webpack_require__.r(__webpack_exports__);
1062810632
},
1062910633
responseType: 'json'
1063010634
}).then(function (res) {
10631-
// console.log(res.data);
10635+
console.log(res.data);
10636+
1063210637
if (res.data.success == true) {
1063310638
toastr.success('Table Updated Successfully.');
1063410639

@@ -10769,7 +10774,7 @@ __webpack_require__.r(__webpack_exports__);
1076910774
});
1077010775
},
1077110776
getIndex: function getIndex(field) {
10772-
console.log(field);
10777+
// console.log(field);
1077310778
var _iteratorNormalCompletion5 = true;
1077410779
var _didIteratorError5 = false;
1077510780
var _iteratorError5 = undefined;
@@ -123736,56 +123741,55 @@ var render = function() {
123736123741
])
123737123742
]
123738123743
)
123739-
: _vm._e(),
123740-
_vm._v(" "),
123741-
_c("div", { staticClass: "row" }, [
123742-
_c("div", { staticClass: "col-sm-12 col-md-5" }, [
123743-
_c(
123744-
"div",
123745-
{
123746-
staticClass: "dataTables_info",
123747-
attrs: {
123748-
id: "database-table_info",
123749-
role: "status",
123750-
"aria-live": "polite"
123751-
}
123752-
},
123753-
[
123754-
_vm._v(
123755-
"Showing " +
123756-
_vm._s(_vm.pagination.from) +
123757-
" to " +
123758-
_vm._s(_vm.pagination.to) +
123759-
" of " +
123760-
_vm._s(_vm.pagination.total) +
123761-
" entries"
123762-
)
123763-
]
123764-
)
123765-
]),
123766-
_vm._v(" "),
123767-
_c(
123768-
"div",
123769-
{ staticClass: "col-sm-12 col-md-7" },
123770-
[
123771-
_c("pagination", {
123772-
attrs: {
123773-
data: _vm.pagination,
123774-
limit: 2,
123775-
align: "right"
123776-
},
123777-
on: {
123778-
"pagination-change-page":
123779-
_vm.fetchDatabaseTables
123780-
}
123781-
})
123782-
],
123783-
1
123784-
)
123785-
])
123744+
: _vm._e()
123786123745
])
123787123746
: _vm._e(),
123788123747
_vm._v(" "),
123748+
_c("div", { staticClass: "row" }, [
123749+
_c("div", { staticClass: "col-sm-12 col-md-5" }, [
123750+
_c(
123751+
"div",
123752+
{
123753+
staticClass: "dataTables_info",
123754+
attrs: {
123755+
id: "database-table_info",
123756+
role: "status",
123757+
"aria-live": "polite"
123758+
}
123759+
},
123760+
[
123761+
_vm._v(
123762+
"Showing " +
123763+
_vm._s(_vm.pagination.from) +
123764+
" to " +
123765+
_vm._s(_vm.pagination.to) +
123766+
" of " +
123767+
_vm._s(_vm.pagination.total) +
123768+
" entries"
123769+
)
123770+
]
123771+
)
123772+
]),
123773+
_vm._v(" "),
123774+
_c(
123775+
"div",
123776+
{ staticClass: "col-sm-12 col-md-7" },
123777+
[
123778+
_c("pagination", {
123779+
attrs: {
123780+
data: _vm.pagination,
123781+
limit: 2,
123782+
align: "right"
123783+
},
123784+
on: {
123785+
"pagination-change-page": _vm.fetchDatabaseTables
123786+
}
123787+
})
123788+
],
123789+
1
123790+
)
123791+
]),
123792+
_vm._v(" "),
123789123793
_vm.isModalComponent
123790123794
? _c("database-modals", {
123791123795
attrs: {

resources/assets/js/components/modals/RecordModals.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
data: formData,
244244
responseType: 'json',
245245
}).then(res => {
246-
// console.log(res.data);
246+
console.log(res.data);
247247
if( res.data.success == true ){
248248
toastr.success("Record Added successfully.");
249249
this.$emit('fresh');
@@ -254,7 +254,7 @@
254254
255255
})
256256
.catch(err => {
257-
// console.log(err.response);
257+
console.log(err.response);
258258
this.$Progress.fail()
259259
this.displayError(err.response);
260260
});
@@ -273,7 +273,7 @@
273273
data: formData,
274274
responseType: 'json',
275275
}).then(res => {
276-
// console.log(res.data);
276+
console.log(res.data);
277277
if( res.data.success == true ){
278278
toastr.success("Record Updated successfully.");
279279
this.$emit('fresh');
@@ -284,7 +284,7 @@
284284
285285
})
286286
.catch(err => {
287-
// console.log(err.response);
287+
console.log(err.response);
288288
this.$Progress.fail()
289289
this.displayError(err.response);
290290
});

resources/assets/js/views/Database.vue

+11-11
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@
9494
</tr>
9595
</tfoot>
9696
</table>
97+
</div>
9798

98-
<div class="row">
99-
<div class="col-sm-12 col-md-5">
100-
<div class="dataTables_info" id="database-table_info" role="status" aria-live="polite">Showing {{ pagination.from }} to {{ pagination.to }} of {{ pagination.total }} entries</div>
101-
</div>
102-
<div class="col-sm-12 col-md-7">
103-
<pagination
104-
:data="pagination"
105-
:limit="2"
106-
align="right"
107-
@pagination-change-page="fetchDatabaseTables"></pagination>
108-
</div>
99+
<div class="row">
100+
<div class="col-sm-12 col-md-5">
101+
<div class="dataTables_info" id="database-table_info" role="status" aria-live="polite">Showing {{ pagination.from }} to {{ pagination.to }} of {{ pagination.total }} entries</div>
102+
</div>
103+
<div class="col-sm-12 col-md-7">
104+
<pagination
105+
:data="pagination"
106+
:limit="2"
107+
align="right"
108+
@pagination-change-page="fetchDatabaseTables"></pagination>
109109
</div>
110110
</div>
111111

resources/assets/js/views/database/Builder.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
responseType: 'json',
199199
})
200200
.then(res => {
201-
// console.log(res.data);
201+
console.log(res.data);
202202
if( res.data.success == true ){
203203
toastr.success('Table Updated Successfully.');
204204
if(this.oldTable != this.tableName) {
@@ -282,7 +282,7 @@
282282
283283
},
284284
getIndex: function(field) {
285-
console.log(field);
285+
// console.log(field);
286286
for(var index of this.indexes) {
287287
var columns = index.columns;
288288
if(columns.includes(field.name)) {

src/Database/Drivers/MongoDB.php

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ public function setFields($collectionName, $fields)
146146
*/
147147

148148
if ($collection->count() > 0) {
149-
$sets = [];
150149
foreach ($newFields as $newField) {
151150
$cursor = $collection->find();
152151
$iterator = iterator_to_array($cursor);

src/Database/Drivers/MongoDB/Type.php

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Type
3232
'null',
3333
'integer',
3434
'longInteger',
35+
'relationship',
3536
];
3637
public static function binary(string $value, int $type = Binary::TYPE_GENERIC)
3738
{
@@ -131,6 +132,11 @@ public static function longInteger($value)
131132
return (int) $value;
132133
}
133134

135+
public static function relationship($value)
136+
{
137+
return $value;
138+
}
139+
134140
public static function getTypes()
135141
{
136142
return (array) self::$types;

src/Http/Controllers/DatabaseController.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ public function updateMongoDbTable($table)
9393

9494
if (in_array($column['oldName'], $fieldNames)) {
9595

96-
$collection_field = CollectionField::where('old_name', $column['oldName'])->first();
96+
$collection_field = $collection_field = CollectionField::where([
97+
'dbm_collection_id' => $collection->_id,
98+
'old_name' => $column['oldName'],
99+
])->first();
97100

98101
$collection_field->name = $column['name'];
99102
$collection_field->old_name = $column['oldName'];
@@ -241,7 +244,8 @@ public function update(Request $request)
241244

242245
if (Driver::isMongoDB()) {
243246

244-
$this->updateMongoDbTable($table);
247+
$table = $this->updateMongoDbTable($table);
248+
245249
}
246250

247251
// Update Database

src/Http/Controllers/RecordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function store(Request $request)
6666
}
6767

6868
if ($table->save()) {
69-
$this->storeRelationshipData($fields, $columns, $object, $table);
69+
$relationship = $this->storeRelationshipData($fields, $columns, $object, $table);
7070
return response()->json(['success' => true, 'object' => $object, 'table' => $table]);
7171
}
7272

src/Traits/RecordRelationship.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ public function updateRelationshipData($fields, $columns, $object, $table)
125125
$pivotTable = $relationship->pivotTable;
126126
$parentPivotKey = $relationship->parentPivotKey;
127127
$relatedPivotKey = $relationship->relatedPivotKey;
128-
129-
$findColumn = $object->details['findColumn'];
128+
$findColumn = $object->details['findColumn'];
130129

131130
$localObject = DBM::model($localModel, $localTable)->where($findColumn, $table->{$findColumn})->first();
132131

src/Traits/RecordTrait.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function prepareStoreField($value, $tableName, $column)
6464
$this->generateError([$fieldType . " type not supported."]);
6565
}
6666

67-
$value = Type::$fieldType($value);
67+
if ($fieldType != 'timestamp') {
68+
$value = Type::$fieldType($value);
69+
}
6870

6971
}
7072

0 commit comments

Comments
 (0)