@scriptpilot/vue-mixin-database
v1.0.1
Published
Provides a persistent "database" object for Vue applications.
Downloads
1
Readme
Database Mixin for Vue Applications
Provides a persistent "database" object for Vue applications.
Installation
Run
npm install --save @scriptpilot/vue-mixin-database
to install the packageAdd the mixin to your Vue application:
import Vue from 'vue' import databaseMixin from '@scriptpilot/vue-mixin-database' ... Vue.mixin(databaseMixin) ... new Vue(...)
Usage
To read: $db('path')
To write: $db('path', 'value')
To delete: $db('path', null)
path
to be used according https://lodash.com/docs/4.17.15#set.
Examples
In the template:
<template>
<p>Value: {{$db('key')}}</p>
<p><button @click="$db('key', 'new value')">Update the Value</button></p>
<p><button @click="$db('key', null)">Delete the Value</button></p>
</template>
In the script:
<script>
export default {
created() {
this.$db('key', 'old value')
}
}
</script>