Last change
on this file since 443 was
443,
checked in by hendrikvanantwerpen, 12 years ago
|
Reorganized for Node --- the SVN gods hate us all!
Lost all historical info on moved files, because SVN is a f *.
Also we have Node now, serving both the static content and forwarding
database requests.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[443] | 1 | define([ |
---|
| 2 | 'dojo/date/stamp', |
---|
| 3 | 'dojo/store/Cache', |
---|
| 4 | 'dojo/store/Memory', |
---|
| 5 | 'dojox/json/schema', |
---|
| 6 | './model/schema', |
---|
| 7 | './store/CouchStore' |
---|
| 8 | ],function(stamp,Cache,Memory,jsonSchema,schema,CouchStore){ |
---|
| 9 | |
---|
| 10 | var couchStore = new CouchStore({ |
---|
| 11 | target: 'data/couch/' /*, |
---|
| 12 | validate: function(object) { |
---|
| 13 | var result = jsonSchema.validate(object,schema); |
---|
| 14 | if ( result.valid ) { |
---|
| 15 | return true; |
---|
| 16 | } else { |
---|
| 17 | console.log("Found error ",result," for invalid object ",object); |
---|
| 18 | return false; |
---|
| 19 | } |
---|
| 20 | }*/ |
---|
| 21 | }); |
---|
| 22 | var memoryStore = new Memory({ |
---|
| 23 | idProperty: couchStore.idProperty |
---|
| 24 | }); |
---|
| 25 | var cacheStore = new Cache(couchStore,memoryStore,{ |
---|
| 26 | isLoaded: function(object) { |
---|
| 27 | // Unfortunately we cannot determine of the full documents were |
---|
| 28 | // loaded or not. Therefore never cache query results. |
---|
| 29 | return false; |
---|
| 30 | } |
---|
| 31 | }); |
---|
| 32 | |
---|
| 33 | var store = cacheStore; |
---|
| 34 | store.formatDate = function(date){ |
---|
| 35 | return stamp.toISOString(date,{zulu:true}); |
---|
| 36 | }; |
---|
| 37 | store.parseDate = function(dateString){ |
---|
| 38 | return stamp.fromISOString(dateString); |
---|
| 39 | }; |
---|
| 40 | store.timestamp = function() { |
---|
| 41 | return this.formatDate(new Date()); |
---|
| 42 | }; |
---|
| 43 | return store; |
---|
| 44 | |
---|
| 45 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.