4 ms·
> You don't need to worry about updating the schema at the db level What's your magic non-db level, supposedly-easier-than-updating-a-schema approach to renami
by integraton 13y ago
> You don't need to worry about updating the schema at the db level
What's your magic non-db level, supposedly-easier-than-updating-a-schema approach to renaming a field common to all existing documents in a collection, eg, rename an "author" field to "writer"?
- dodyg 13y agoThis is where a nice query/manipulation language come handy http://www.rethinkdb.com/api/#js http://www.rethinkdb.com/api/#js
- integraton 13y agoAgreed. PostgreSQL: ALTER TABLE posts RENAME COLUMN author TO writer; MongoDB: db.posts.update({}, {$rename:{"author":"writer"}}, false, true); (I'm excluding RethinkDB since it's still under development and doesn't have a rename command yet)
- orthecreedence 13y agoI don't think it really needs a `rename` command. The query language supports it without: r.table('posts').replace(function(item) { return item.without('author').merge({writer: item('name')}); })
- coffeemug 13y agoThat works, but it is a bit annoying to type. We'll add a porcelain command for this soon. See https://github.com/rethinkdb/rethinkdb/issues/881 https://github.com/rethinkdb/rethinkdb/issues/881.