Last change
on this file since 525 was
525,
checked in by hendrikvanantwerpen, 11 years ago
|
- Allow empty subcodes.
- Use HTTPResult exclusively on server (no more q).
- Set readonly & disabled on ourselves as well in _ComplexValueMixin
- Split server into several modules.
- Check codes on the variable level, not question level.
- We can add modules in design documents now.
|
File size:
892 bytes
|
Line | |
---|
1 | var env = require('../env') |
---|
2 | , upgradeCouch = require('../config/upgrade-couchdb') |
---|
3 | , cryptoken = require('../util/crypto-token') |
---|
4 | , HTTPResult = require('../util/http-result') |
---|
5 | , _ = require('underscore') |
---|
6 | ; |
---|
7 | |
---|
8 | function flatten(obj,prefix,newObj) { |
---|
9 | prefix = prefix || ""; |
---|
10 | newObj = newObj || {}; |
---|
11 | _.each(obj,function(val,key){ |
---|
12 | key = key.replace(/^[0-9]+\//,''); |
---|
13 | if ( _.isObject(val) && !_.isArray(val) ) { |
---|
14 | flatten(val,prefix+key,newObj); |
---|
15 | } else { |
---|
16 | newObj[prefix+key] = val; |
---|
17 | } |
---|
18 | }); |
---|
19 | return newObj; |
---|
20 | } |
---|
21 | |
---|
22 | upgradeCouch(env.couchServerURL,env.dbName,function(doc){ |
---|
23 | if ( doc.type === "Response" ) { |
---|
24 | doc.answers = flatten(doc.answers); |
---|
25 | return doc; |
---|
26 | } else { |
---|
27 | return HTTPResult.fail(); |
---|
28 | } |
---|
29 | }).then(function(res){ |
---|
30 | console.log("done",res); |
---|
31 | }, function(err){ |
---|
32 | console.error("fail",err); |
---|
33 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.