npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@atlascity/vuex-orm-plugin-lokijs

v0.0.3

Published

vuex-orm LokiJS persistance plugin.

Downloads

3

Readme

vuex-orm-plugin-loki

npm version vue2

vuex-orm LokiJS persistance (Local Storage) plugin, with optional AES encryption.

Installation

npm install @atlascity/vuex-orm-plugin-lokijs

Why & How

* We needed a persistent Local Storage based database.
* VuexORM is a ORM tool for Vuex, this plugin adds the ability to use LokiJS as a persistant store. When you initialize your VuexORM database, the plugin will hydrate VuexORM with data stored in Local Storage (preserving original IDs).

Caveats

Only some of VuexORM model methods are currently implemented. There is no support for VuexORM relationships, you have to manage that yourself. Feel free to contribute!

Examples

$all

$insert

import MyModel from './models/MyModel';
const data = { name: 'Bob' };
MyModel.$insert({ data }); // insert data using $insert() instead of regular insert()

// retrieve data using regular VuexORM query()
const bob = MyModel.query().where('name', 'Bob').get();

$update

MyModel.$update({
  where: record => record.name === 'Bob',
  data: { name: 'Bobby' },
});

$delete

const bobby = MyModel.query().where('name', 'Bobby').get();
MyModel.$delete(bobby.id);

$update

import MyModel from './models/MyModel';

MyModel.$update({
  where: (record) => { return record.id === id; },
  data: { example: 'data' },
});

Usage

import Vue from 'vue';
import Vuex from 'vuex';
import VuexORM from '@vuex-orm/core';
import VuexORMLoki from 'vuex-orm-lokijs';
import { Model } from '@vuex-orm/core';

// define your VuexORM model
class MyModel extends Model {
  static entity = 'MyModel';
  static fields() {
    return {
      id: this.increment(),
      data: this.attr(''),
    };
  }
}

Vue.use(Vuex);
const database = new VuexORM.Database();
database.register(MyModel, {});

const options = {
  env: 'browser',
};

function hydrationCompletedCallback() {
  // data from LocalStorage has been fully loaded into VuexORM
}

VuexORM.use(VuexORMLoki, { database, options, hydrationCompletedCallback });

const store = new Vuex.Store({
  plugins: [VuexORM.install(database)],
});

Encryption

Encryption currently only works on $insert().

Setup the model

import { Model } from '@vuex-orm/core';

export default MyModel extends Model {
  static entity = 'MyModel';
  static AES = ['secretProperty1', 'secretProperty2']; // tell the plugin what to encrypt

  static fields() {
    return {
      id: this.increment(),
      name: this.attr(),
      secretProperty1: this.attr(),
      secretProperty2: this.attr(),
    };
  }
}

Insert data with password

import MyModel from './models/MyModel';
const data = {
  name: 'Bob',
  secretProperty1: 'Very sensitive data',
  secretProperty2: 'Even more',
};

const password = "your password";

/*
 * before being put into the database, the data
 * will be encrypted with AES using the password
 */
MyModel.$insert({ data, password }); // pass the password

Update data with password

import MyModel from './models/MyModel';
const data = {
  name: 'Bob',
  secretProperty1: 'Very sensitive data',
  secretProperty2: 'Even more',
};

const password = "your password";

/*
 * before being put into the database, the data
 * will be encrypted with AES using the password
 */
MyModel.$update({ data, password }); // pass the password

Retrieve data and decrypt

import AES from 'crypto-js/aes';
import encUTF8 from 'crypto-js/enc-utf8';
import MyModel from './models/MyModel';

function decrypt(data, password) {
  const bytes = AES.decrypt(data, password);
  return JSON.parse(bytes.toString(encUTF8));
}

const bob = MyModel.query().where('name', 'Bob').get();

MyModel.AES.forEach((key) => {
  bob[key] = decrypt(bob[key], password);
});

:scroll: Changelog

Details changes for each release are documented in the CHANGELOG.md.

:exclamation: Issues

Please make sure to read the Issue Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.

:muscle: Contribution

Please make sure to read the Contributing Guide before making a pull request.

Contributors

Here are the wonderfull soles who contribute to this project

:copyright: License

GPL-2.0-only