FatFractal customer forums



Author Topic: How to rename a column?  (Read 720 times)

hikuimiao

  • Newbie
  • *
  • Posts: 1
    • View Profile
How to rename a column?
« on: March 18, 2015, 02:53:16 AM »
Is there any way to rename a column?

gkc

  • Administrator
  • *****
  • Posts: 375
    • View Profile
Re: How to rename a column?
« Reply #1 on: March 19, 2015, 06:17:44 PM »
Currently no. However very simply dealt with: just create a server extension to modify any existing data. Add this your application.ffdl
Code: [Select]
create extension /renameSomeField as javascript:require('scripts/Extensions.js').renameSomeField();
and in ff-scripts/Extensions.js put this:
Code: [Select]
var ff = require('ffef/FatFractal');
exports.renameSomeField = function() {
  var cursor = ff.getCursorForQuery('/MyCollection/(myOldField ne null)');
  while (cursor.hasNext()) {
    var obj = cursor.next().value;
    obj['myNewField'] = obj['myOldField'];
    delete obj['myOldField'];
    ff.updateObj(obj);
  }
};

 

Copyright © FatFractal customer forums