Question

I'm trying to use taffydb with durandal. I'm able to add simple json-data to a ko.observableArray() (a colleague showed me how :-) ).

Now I want to save it using taffydb.

main.js:

requirejs.config({
  paths: {
   'taffy': '../lib/db-master/taffy'
    ...
  }
});

participant.js:

define(['durandal/app', 'knockout', 'models/user', 'taffy'], function (app, ko, user, taffy) {
...
}

Whenever I add this:

var db = taffy;
db.insert({record:1, data:"test"});

I get this error:

Uncaught TypeError: Cannot call method 'insert' of undefined

Leaving it out will add test-data as expected. Am I 'holding' durandal the wrong way?

regards Claus

Was it helpful?

Solution

If this code is the one you are loading, then you need a shim in the configuration you pass to RequireJS because taffy is not AMD-aware. I believe this should work:

shim: {
    taffy: {
        exports: "TAFFY"
    }
}

I've never used taffy so I'm not aware what its dependencies might be. You might need to add a deps: [...] field to the shim so that the dependencies are loaded ahead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top