From d57cb20e6bca79fe8ef2ae3c7d7917c7d61dde07 Mon Sep 17 00:00:00 2001 From: Sercan Date: Sun, 3 Jan 2016 18:12:56 +0200 Subject: [PATCH] date format changed as YYYY-MM-DD, insertMany implemented --- client/views/pages/browse_collection.js | 3 +++ .../query_templates/aggregate/aggregate.html | 2 +- client/views/query_templates/count/count.html | 2 +- .../create_index/create_index.html | 2 +- .../views/query_templates/delete/delete.html | 2 +- .../query_templates/distinct/distinct.html | 2 +- client/views/query_templates/find/find.html | 2 +- .../query_templates/findone/findone.html | 2 +- .../findone_and_delete.html | 2 +- .../findone_and_replace.html | 4 ++-- .../findone_and_update.html | 4 ++-- .../insert_many/insert_many.html | 2 +- .../query_templates/is_capped/isCapped.js | 15 +++++++++++++ .../query_templates/is_capped/is_capped.html | 2 ++ .../geo_haystack_search_options.html | 2 +- .../geo_near_options/geo_near_options.html | 2 +- lib/enums.js | 3 ++- server/mongodb_helper.js | 22 +++++++++---------- server/mongodb_methods.js | 12 +++++++++- 19 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 client/views/query_templates/is_capped/isCapped.js create mode 100644 client/views/query_templates/is_capped/is_capped.html diff --git a/client/views/pages/browse_collection.js b/client/views/pages/browse_collection.js index 76a3fbe..ed45b5b 100644 --- a/client/views/pages/browse_collection.js +++ b/client/views/pages/browse_collection.js @@ -80,6 +80,9 @@ Template.browseCollection.helpers({ case QUERY_TYPES.GEO_HAYSTACK_SEARCH: return Spacebars.SafeString('This query executes a geo search using a geo haystack index on a collection'); + case QUERY_TYPES.IS_CAPPED: + return Spacebars.SafeString('Returns if the collection is a capped collection'); + default: return ''; } diff --git a/client/views/query_templates/aggregate/aggregate.html b/client/views/query_templates/aggregate/aggregate.html index c2b6a27..a5a6e53 100644 --- a/client/views/query_templates/aggregate/aggregate.html +++ b/client/views/query_templates/aggregate/aggregate.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/count/count.html b/client/views/query_templates/count/count.html index 6ed4465..e5bf655 100644 --- a/client/views/query_templates/count/count.html +++ b/client/views/query_templates/count/count.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/create_index/create_index.html b/client/views/query_templates/create_index/create_index.html index 1588872..bd451eb 100644 --- a/client/views/query_templates/create_index/create_index.html +++ b/client/views/query_templates/create_index/create_index.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/delete/delete.html b/client/views/query_templates/delete/delete.html index 48d80fa..8abb2b4 100644 --- a/client/views/query_templates/delete/delete.html +++ b/client/views/query_templates/delete/delete.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/distinct/distinct.html b/client/views/query_templates/distinct/distinct.html index 35d18c4..fbd4513 100644 --- a/client/views/query_templates/distinct/distinct.html +++ b/client/views/query_templates/distinct/distinct.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/find/find.html b/client/views/query_templates/find/find.html index aa891df..654aa1a 100644 --- a/client/views/query_templates/find/find.html +++ b/client/views/query_templates/find/find.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/findone/findone.html b/client/views/query_templates/findone/findone.html index 8e7937c..8daff9b 100644 --- a/client/views/query_templates/findone/findone.html +++ b/client/views/query_templates/findone/findone.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/findone_and_delete/findone_and_delete.html b/client/views/query_templates/findone_and_delete/findone_and_delete.html index 13ca69a..1822394 100644 --- a/client/views/query_templates/findone_and_delete/findone_and_delete.html +++ b/client/views/query_templates/findone_and_delete/findone_and_delete.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/findone_and_replace/findone_and_replace.html b/client/views/query_templates/findone_and_replace/findone_and_replace.html index 3e6ab75..2a0d7e6 100644 --- a/client/views/query_templates/findone_and_replace/findone_and_replace.html +++ b/client/views/query_templates/findone_and_replace/findone_and_replace.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
@@ -12,7 +12,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/findone_and_update/findone_and_update.html b/client/views/query_templates/findone_and_update/findone_and_update.html index 973718a..a8de320 100644 --- a/client/views/query_templates/findone_and_update/findone_and_update.html +++ b/client/views/query_templates/findone_and_update/findone_and_update.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
@@ -12,7 +12,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates/insert_many/insert_many.html b/client/views/query_templates/insert_many/insert_many.html index 9d5d8f7..fb38233 100644 --- a/client/views/query_templates/insert_many/insert_many.html +++ b/client/views/query_templates/insert_many/insert_many.html @@ -3,7 +3,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
Furthermore, you can provide an array to insert multiple docs, or an object for single one
diff --git a/client/views/query_templates/is_capped/isCapped.js b/client/views/query_templates/is_capped/isCapped.js new file mode 100644 index 0000000..3544542 --- /dev/null +++ b/client/views/query_templates/is_capped/isCapped.js @@ -0,0 +1,15 @@ +/** + * Created by RSercan on 3.1.2016. + */ +Template.isCapped.executeQuery = function () { + Template.browseCollection.initExecuteQuery(); + var connection = Connections.findOne({_id: Session.get(Template.strSessionConnection)}); + var selectedCollection = Session.get(Template.strSessionSelectedCollection); + + Meteor.call("isCapped", connection, selectedCollection, function (err, result) { + if (!result.result) { + result.result = false; + } + Template.renderAfterQueryExecution(err, result); + }); +}; \ No newline at end of file diff --git a/client/views/query_templates/is_capped/is_capped.html b/client/views/query_templates/is_capped/is_capped.html new file mode 100644 index 0000000..fb88859 --- /dev/null +++ b/client/views/query_templates/is_capped/is_capped.html @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/client/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options.html b/client/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options.html index 7983db7..bda80ac 100644 --- a/client/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options.html +++ b/client/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options.html @@ -15,7 +15,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/client/views/query_templates_options/geo_near_options/geo_near_options.html b/client/views/query_templates_options/geo_near_options/geo_near_options.html index 75b452e..6075763 100644 --- a/client/views/query_templates_options/geo_near_options/geo_near_options.html +++ b/client/views/query_templates_options/geo_near_options/geo_near_options.html @@ -77,7 +77,7 @@

-            You can use string to query ISODate and ObjectID, date format is DD.MM.YYYY
+            You can use string to query ISODate and ObjectID, date format is YYYY-MM-DD
                 HH:mm:ss
         
diff --git a/lib/enums.js b/lib/enums.js index f94af8f..59f40a1 100644 --- a/lib/enums.js +++ b/lib/enums.js @@ -16,7 +16,8 @@ QUERY_TYPES = { GEO_HAYSTACK_SEARCH: "geoHaystackSearch", GEO_NEAR: "geoNear", INDEX_INFORMATION: "indexInformation", - INSERT_MANY: "insertMany" + INSERT_MANY: "insertMany", + IS_CAPPED : "isCapped" }; GEO_NEAR_OPTIONS = { diff --git a/server/mongodb_helper.js b/server/mongodb_helper.js index 953fdb6..052a704 100644 --- a/server/mongodb_helper.js +++ b/server/mongodb_helper.js @@ -9,17 +9,17 @@ getConnectionUrl = function (connection) { connectionUrl += connection.host + ':' + connection.port + '/' + connection.databaseName; return connectionUrl; -} +}; convertBSONtoJSON = function (obj) { convertObjectIDsToString(obj); convertDatesToString(obj); -} +}; convertJSONtoBSON = function (obj) { convertValidObjectIds(obj); convertValidDates(obj); -} +}; var convertDatesToString = function (obj) { @@ -34,13 +34,13 @@ var convertDatesToString = function (obj) { } } else { - if (obj[property] instanceof Date) { - obj[property] = moment(obj[property]).format('DD.MM.YYYY HH:mm:ss'); + if (Object.prototype.toString.call(obj[property]) === '[object Date]') { + obj[property] = moment(obj[property]).format('YYYY-MM-DD HH:mm:ss.SSS'); } } } } -} +}; var convertObjectIDsToString = function (obj) { var objectID = Meteor.npmRequire('mongodb').ObjectID; @@ -62,7 +62,7 @@ var convertObjectIDsToString = function (obj) { } } } -} +}; var convertValidObjectIds = function (obj) { var objectID = Meteor.npmRequire('mongodb').ObjectID; @@ -84,7 +84,7 @@ var convertValidObjectIds = function (obj) { } } } -} +}; var convertValidDates = function (obj) { for (var property in obj) { @@ -98,10 +98,10 @@ var convertValidDates = function (obj) { } } else { - if (moment(obj[property].toString(), 'DD.MM.YYYY HH:mm:ss', true).isValid()) { - obj[property] = moment(obj[property].toString(), 'DD.MM.YYYY HH:mm:ss', true).toDate(); + if (moment(obj[property].toString(), 'YYYY-MM-DD HH:mm:ss', true).isValid()) { + obj[property] = moment(obj[property].toString(), 'YYYY-MM-DD HH:mm:ss', true).toDate(); } } } } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/server/mongodb_methods.js b/server/mongodb_methods.js index 6997456..d6c8f38 100644 --- a/server/mongodb_methods.js +++ b/server/mongodb_methods.js @@ -22,6 +22,15 @@ Meteor.methods({ }); }, + 'isCapped': function (connection, selectedCollection) { + var methodArray = [ + { + "isCapped": [] + } + ]; + return proceedQueryExecution(connection, selectedCollection, methodArray); + }, + 'insertMany': function (connection, selectedCollection, docs) { var methodArray = [ { @@ -206,8 +215,9 @@ var proceedQueryExecution = function (connection, selectedCollection, methodArra for (var i = 0; i < methodArray.length; i++) { var last = i == (methodArray.length - 1); var entry = methodArray[i]; - for (var key in entry) { + convertJSONtoBSON(entry); + for (var key in entry) { if (last && key == Object.keys(entry)[Object.keys(entry).length - 1]) { entry[key].push(function (err, docs) { done(err, docs); -- GitLab