typicaljoe / taffydb

TaffyDB - an open source JavaScript Database for your browser
http://taffydb.com
MIT License
2.21k stars 285 forks source link

How to include TAFFY in Webpack based project ? #117

Open ladvishal1985 opened 8 years ago

ladvishal1985 commented 8 years ago

I see that TAFFY included support for AMD. But I am unable to find a way on how to include within my project to use it. Any reference or any pointer on the same shall help a lot.

bradisbell commented 8 years ago

I use:

import {taffy} from 'taffydb';

const db = taff();
db.insert(/* data */);
csterritt commented 7 years ago

Fails for me:

[1] App threw an error during load
[1] Error: Cannot find module 'taffydb'

The instructions in the README.md say:

$ npm install --production taffy

So I'd think:

import {taffy} from 'taffy'

would work, but that fails as well.

STOP THE PRESSES Turns out I just hadn't tried enough permutations yet!

The following works:

import taffy from 'taffy'

const db = taffy()
db.insert(/* data */)
bradisbell commented 7 years ago

@csterritt Just an FYI, the README is wrong. There are two NPM packages. One is taffy, and the other is taffydb. taffydb is what points to the @typicaljoe fork.

bradisbell commented 7 years ago

Figured out one other important part of this... you must exclude node_modules/taffydb if you're using Babel for transpiling.

csterritt commented 7 years ago

@bradisbell Thanks, I'll try that out.

marventu94 commented 3 years ago

I have the same problem. I will resolve doing this: 1) Download taffy-min.js on official page 2) Move this file to /plugin folder on your project 3) In the file .vue that you need use. Copy this line on script section

import { taffy } from '@/plugins/taffy-min.js';

4) And on mounted()methods you can write:

const friends = taffy([                                 {"id":1,"gender":"M","first":"John","last":"Smith","city":"Seattle, WA","status":"Active"},                     {"id":2,"gender":"F","first":"Kelly","last":"Ruth","city":"Dallas, TX","status":"Active"},
                                {"id":3,"gender":"M","first":"Jeff","last":"Stevenson","city":"Washington, D.C.","status":"Active"},
                                {"id":4,"gender":"F","first":"Jennifer","last":"Gill","city":"Seattle, WA","status":"Active"}   
                            ]);

More: if you are using Typerscript, dont forget write "declare module '@/plugins/taffy-min.js';" on "delcarations.d.ts" on src folder to work.

I hope work for you! Sorry for my english! :)