Skip to content

nitaking/sequelize-tinker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sequelize-tinker

A REPL for sequelize inspired by Laravel Tinker.

oclif Version CircleCI Codecov Downloads/week License

2020-02-01 23 04 37

Buy Me A Coffee

Introduction

$ npm -g install sequelize-tinker
$ cd path/to/your-sequelize-package
$ sequelize-tinker

Usage

$ sequelize-tinker
>> Start sequelize-tinker! 
...
>> models
# [ 'Task', 'User' ]
$ sequelize-tinker
>> Start sequelize-tinker! 
...
>> User.findOne({ raw: true })
Executing (default): SELECT `id`, `firstName`, `lastName`, `createdAt`, `updatedAt` FROM `Users` AS `User` LIMIT 1;
{ id: 1,
  firstName: 'John',
  lastName: 'Doe',
  createdAt: 2020-02-01T12:50:17.000Z,
  updatedAt: 2020-02-01T12:50:17.000Z }
$ sequelize-tinker
>> Start sequelize-tinker! 
...
>> const u = await User.findOne({ raw: true, where: { id: 49197 }  })
undefined
>> u.email
'email_49197@example.com'
>> 

Advance

Custom your directory:

Custom Models Dir: --models-path option.

$ sequelize-tinker --models-path=models/index.js        

Todo

  • Custom Sequelize model's directory path setting.
  • Available await command.
  • Option
    • Default output JSON.stringify
  • Command
    • ls (show local variables)
    • help (show help in repl time)
  • Multi Line

Roadmap

  1. ts-node(for TypeScript sequelize)
  2. Another ORM
    • TypeORM

Contribution

git clone git@github.com:nitaking/sequelize-tinker.git
cd example
./bin/run
another sequelize project
# fork from git@github.com:nitaking/sequelize-tinker.git
npm link
cd another/prj
sequelize-tinker # Uninstall if you have installed.