[Groonga-commit] groonga/groonga-admin at f3d6941 [master] schema: set properties for easy to use

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 30 20:11:08 JST 2014


Kouhei Sutou	2014-12-30 20:11:08 +0900 (Tue, 30 Dec 2014)

  New Revision: f3d694183a09c67916ce3998e3a0669777049241
  https://github.com/groonga/groonga-admin/commit/f3d694183a09c67916ce3998e3a0669777049241

  Message:
    schema: set properties for easy to use

  Modified files:
    app/scripts/groonga-client/response/column-list.js
    app/scripts/groonga-client/response/table-list.js
    app/scripts/services/schema-loader.js

  Modified: app/scripts/groonga-client/response/column-list.js (+5 -2)
===================================================================
--- app/scripts/groonga-client/response/column-list.js    2014-12-30 18:46:53 +0900 (85937ac)
+++ app/scripts/groonga-client/response/column-list.js    2014-12-30 20:11:08 +0900 (c6c0079)
@@ -21,7 +21,10 @@
   ColumnList.prototype.columns = function() {
     var parameters = this.parameters();
     return this.body().slice(1).map(function(columnProperties) {
-      var column = {};
+      var column = {
+        properties: {},
+        rawProperties: columnProperties
+      };
       parameters.forEach(function(parameter, index) {
         var name = parameter.name;
         var value = columnProperties[index];
@@ -33,7 +36,7 @@
           name = 'sources';
           break;
         }
-        column[name] = value;
+        column[name] = column.properties[name] = value;
       });
       column.isScalar = column.flags.indexOf('COLUMN_SCALAR') != -1;
       column.isVector = column.flags.indexOf('COLUMN_VECTOR') != -1;

  Modified: app/scripts/groonga-client/response/table-list.js (+5 -2)
===================================================================
--- app/scripts/groonga-client/response/table-list.js    2014-12-30 18:46:53 +0900 (ea7cf7c)
+++ app/scripts/groonga-client/response/table-list.js    2014-12-30 20:11:08 +0900 (d08e6df)
@@ -21,7 +21,10 @@
   TableList.prototype.tables = function() {
     var parameters = this.parameters();
     return this.body().slice(1).map(function(tableProperties) {
-      var table = {};
+      var table = {
+        properties: {},
+        rawProperties: tableProperties
+      };
       parameters.forEach(function(parameter, index) {
         var name = parameter.name;
         var value = tableProperties[index];
@@ -33,7 +36,7 @@
           name = 'sources';
           break;
         }
-        table[name] = value;
+        table[name] = table.properties[name] = value;
       });
       table.isArray          = table.flags.indexOf('TABLE_NO_KEY')   != -1;
       table.isHashTable      = table.flags.indexOf('TABLE_HASH_KEY') != -1;

  Modified: app/scripts/services/schema-loader.js (+23 -4)
===================================================================
--- app/scripts/services/schema-loader.js    2014-12-30 18:46:53 +0900 (8c6bdf7)
+++ app/scripts/services/schema-loader.js    2014-12-30 20:11:08 +0900 (16dcf77)
@@ -93,13 +93,32 @@ angular.module('groongaAdminApp')
         table.columns[column.name] = column;
       }
 
+      function addIDColumn(table) {
+        var properties = {
+          name: '_id',
+          type: 'fix',
+          flags: ['COLUMN_SCALAR', 'PERSISTENT'],
+          domain: table.name,
+          range: 'UInt32',
+          sources: []
+        };
+
+        var rawProperties = angular.copy(properties);
+        rawProperties.source = rawProperties.sources;
+        delete rawProperties.sources;
+        rawProperties.flags = rawProperties.flags.join('|');
+
+        var IDColumn = angular.copy(properties);
+        IDColumn.rawProperties = rawProperties;
+        IDColumn.properties = properties;
+
+        addColumn(table, IDColumn);
+      }
+
       function fetchColumns(table) {
         table.columns = {};
 
-        addColumn(table, {
-          name: '_id',
-          range: 'UInt32'
-        });
+        addIDColumn(table);
 
         return client.execute('column_list', {table: table.name})
           .success(function(response) {
-------------- next part --------------
HTML����������������������������...
Download 



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