[Groonga-commit] groonga/gcs [master] Don't modify the original object given to toGrnDumpRecord

Zurück zum Archiv-Index

SHIMODA Hiroshi null+****@clear*****
Mon Aug 13 13:54:48 JST 2012


SHIMODA Hiroshi	2012-08-13 13:54:48 +0900 (Mon, 13 Aug 2012)

  New Revision: 647887402c0e7137d346c87a7e7792ccdc87f9f9
  https://github.com/groonga/gcs/commit/647887402c0e7137d346c87a7e7792ccdc87f9f9

  Log:
    Don't modify the original object given to toGrnDumpRecord

  Modified files:
    lib/database/domain.js

  Modified: lib/database/domain.js (+6 -9)
===================================================================
--- lib/database/domain.js    2012-08-13 13:50:25 +0900 (414679f)
+++ lib/database/domain.js    2012-08-13 13:54:48 +0900 (612f6ea)
@@ -359,9 +359,12 @@ Domain.prototype = {
   },
 
   toGrnDumpRecord: function(record) {
-    record['_key'] = record['id'];
-    delete record['id'];
-    return record;
+    var grnDumpRecord = {};
+    Object.keys(record).forEach(function(key) {
+      var grnDumpKey = key == '_key' ? 'id' : key ;
+      grnDumpRecord[grnDumpKey] = record[key];
+    });
+    return grnDumpRecord;
   },
 
   addRecordSync: function(record) {
@@ -372,12 +375,6 @@ Domain.prototype = {
     });
   },
 
-  toDumpRecord: function(record) {
-    record['id'] = record['_key'];
-    delete record['_key'];
-    return record;
-  },
-
   deleteRecordSync: function(id) {
     this.context.commandSync('delete', {
       table: this.tableName,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index