[Groonga-commit] groonga/gcs [master] Don't return blank "data" property

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Aug 22 17:46:12 JST 2012


YUKI Hiroshi	2012-08-22 17:46:12 +0900 (Wed, 22 Aug 2012)

  New Revision: a74d7e2644c3826df2156123f41578824aeceadc
  https://github.com/groonga/gcs/commit/a74d7e2644c3826df2156123f41578824aeceadc

  Log:
    Don't return blank "data" property

  Modified files:
    lib/api/2011-02-01/search.js

  Modified: lib/api/2011-02-01/search.js (+8 -9)
===================================================================
--- lib/api/2011-02-01/search.js    2012-08-22 17:43:15 +0900 (df1912e)
+++ lib/api/2011-02-01/search.js    2012-08-22 17:46:12 +0900 (f843850)
@@ -38,28 +38,27 @@ function formatSelectResults(data) {
 
   var records = data[0].slice(2);
   var results = records.map(function(record) {
-    var object = {};
-    var id;
+    var result = {};
+    var data = {};
     columnNames.forEach(function(columnName, index) {
       // bind internal "_key" column to the "id"
       if (columnName == '_key') {
-        id = record[index];
+        result.id = record[index];
         return;
       }
       // don't expose any internal column
       if (columnName[0] == '_') return;
       if (Array.isArray(record[index])) {
         // vector column
-        object[columnName] = record[index];
+        data[columnName] = record[index];
       } else {
         // scalar column
-        object[columnName] = [record[index]];
+        data[columnName] = [record[index]];
       }
     });
-    return {
-      id:   id,
-      data: object
-    };
+    if (Object.keys(data).length)
+      result.data = data;
+    return result;
   });
   return results;
 }
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index