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

smart-mysql-cache

v0.3.17

Published

Smart Keeping Memory Storage in MySQL

Downloads

6

Readme

Smart MySQL Cache

smart-mysql-cache Storing Content The Database In Disk.

So let's build it with JavaScript.

How to Install :

$ npm install smart-mysql-cache

How to connect :

To use this library should we calling cache class.

host , user , password , charset , database , collection is required .

var {cache} = require('smart-mysql-cache');

var collection = {
tbl_user : {
attributes : [
{ name : 'id' , empty : false },
{ name : 'fullname' , empty : '' },
{ name : 'username' , empty : '' },
{ name : 'password' , empty : '' }
]
},
tbl_post : {
attributes : [
{ name : 'id' , empty : false },
{ name : 'title' , empty : '' },
{ name : 'description' , empty : '' },
{ name : 'user' , empty : false , collection : 'tbl_user' }
]
}
};

var db = new cache({ mysql : {
    host : 'localhost',
    user : 'root',
    password : '',
    charset : 'utf8_unicode_ci',
    database : 'avl'
} , collection });

Specify your table :

It’s easy to define which table you wants to work with. You can specify your table name as we have done below.

db.collection('table_name');

Inserting Rows :

We'll show you, That's simple to insert the records.

db.collection('tbl_user').add({ fullname : 'hamid afsordeh' , username : 'hamid' , password : '******' });
db.collection('tbl_post').add({ title : 'The First Post' , description : 'This Is First Post' , user : 1 });

Updating Rows :

Update your table simply. This line update all of your rows with condition. Use put new data in first parameter. Next line will update all of your columns named username.

db.collection('tbl_user').get(5).data = { username : 'hamid_afsordeh' };

This sql query happen for last command:

Update tbl_user set username = 'hamid_afsordeh'

Delete a Row :

It’s simple to delete a row from table with that condition you want or Without any condition as we have done below.

db.collection('tbl_post').get(5).delete;

Last command return this query string:

Delete from tbl_user where id = 5

Selecting Rows :

There is three way to use select function

  1. find
  2. first
  3. get
  4. all
  1. In all function you will take all of rows that you want to be. You can use this parameters for table function.

db.collection('tbl_post').all

You can set condition in second parameter for select

db.collection('tbl_post').filter((post) => { return post.id == 5 });

OR use many condition

db.collection('tbl_post').filter((post) => { return post.id == 5 && post.user == 1 });

find , first and get:

  1. In find , fist and get function you take only one row of table as we have done below. You can use this function like table function. But different is this function fetch first row.

find(filter);

first();

get(id);

db.collection('tbl_user').find({ id: 5 });

db.collection('tbl_user').first();

db.collection('tbl_user').get(5);

Last commands return this query, string.

Select * from tbl_user where id = 5

Select * from tbl_user Limit 1

Select * from tbl_user where id = 5