Reputation: 3
I have an existing project and I want to recode it with VueJs. I need to import a npm package called TaffyDB. I figured out that I have to import it in the main.js. I have to admit that I don't have any idea how to do that or how the syntax is exactly.
import WHAT from "WHERE";
taffydb is installed and I find the folder "taffydb" within my node_modules folder. In that folder is the taffy.js file.
What I don't know is how to find the details for "WHERE" and "WHAT".
Any help is appreciated.
Upvotes: 0
Views: 339
Reputation: 1
I have the same problem. I will resolve doing this:
Download taffy-min.js on official page
Move this file to /plugin folder on your project
In the file .vue that you need use. Copy this line on script section
import { taffy } from '@/plugins/taffy-min.js';
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! :)
Upvotes: 0
Reputation: 287
Do a npm install first on taffy npm install --production taffy
then after that go to the code you want to use it on and require it TAFFY = require( 'taffy' ).taffy;
in the documentation it says require it try it that way instead of doing import from.
Check the documents to https://www.npmjs.com/package/taffydb#use-it-in-nodejs
I hope this helps you out !
Upvotes: 0