New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mysql-relation-query

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-relation-query

module modelling mysql relations

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

mysql-relation-query

###resolves mysql relations create a TableRelationManager, add internal and external columns and have it generate mysql queries, complete with joins and everything

###Imagine the following setup Table posts

  • id
  • title
  • text
  • user_id (foreign key (or not, doesn't matter if it is an actual foreign) targeting users.id

Table users

  • id
  • username

###Then you'd create a relation like this

var TableRelationManager = require('mysql-relation-query');

// base table
var Post = new TableRelationManager('posts')

// columns I want given when querying
Post.addInternalColumn('id');
Post.addInternalColumn('title');
Post.addInternalColumn('text');

// external column relations
// name of column where key (usually primary key, usually id) of reference table is stored
// referenced table
// column (usually primary key, usually id) that is used as reference
// columns I want given when querying that table
Post.addExternalColumn('user_id', 'users', 'id', ['username', 'id']);

console.log(Post.generateQuery('select'));

would generate the following sql statement select posts.id, posts.title, posts.text, users.username as usersusername, users.id as usersid from posts join users on (posts.user_id = users.id)

Keywords

FAQs

Package last updated on 15 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc