Skip to content

Instantly share code, notes, and snippets.

@chrisfosterelli
Last active May 29, 2017 18:54
Show Gist options
  • Save chrisfosterelli/2b91f13ff5b20116154b2bfc5582753f to your computer and use it in GitHub Desktop.
Save chrisfosterelli/2b91f13ff5b20116154b2bfc5582753f to your computer and use it in GitHub Desktop.
/* Update records to clear UTF8 characters
* May 29th, 2017
*/
const r = require('./server/r')
function run(cb) {
r.table('Student')
.replace(student => {
const replace = str => str.split('\u001d').reduce((l, r) => l.add(r))
const first = replace(student('name')('first'))
const last = replace(student('name')('last'))
const name = student('name').merge({ first, last })
return student.merge({ name })
})
.then(rslt => {
console.log('Updated', rslt.replaced, 'students')
process.exit(0)
})
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment