Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 9ad42248
authored
Aug 02, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readme
1 parent
bc5bb265
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
README.md
README.md
View file @
9ad4224
...
@@ -6,36 +6,36 @@ The Sequelize library provides easy access to a MySQL database by mapping databa
...
@@ -6,36 +6,36 @@ The Sequelize library provides easy access to a MySQL database by mapping databa
To get the ball rollin' you first have to create an instance of _Sequelize_. Use it the following way:
To get the ball rollin' you first have to create an instance of _Sequelize_. Use it the following way:
var sequelize = new Sequelize('database', 'username', 'password')
var sequelize = new Sequelize('database', 'username', 'password')
This will save the passed database credentials and provide all further methods.
This will save the passed database credentials and provide all further methods.
The following lines are showing the basic usage:
The following lines are showing the basic usage:
var sequelize = new Sequelize('database', 'username', 'password')
var sequelize = new Sequelize('database', 'username', 'password')
var Project = sequelize.define('Project', {
var Project = sequelize.define('Project', {
name: Sequelize.STRING,
name: Sequelize.STRING,
description: Sequelize.TEXT
description: Sequelize.TEXT
})
})
var Member = sequelize.define('Member', {
var Member = sequelize.define('Member', {
name: Sequelize.STRING,
name: Sequelize.STRING,
firstName: Sequelize.STRING,
firstName: Sequelize.STRING,
hoursPerWeek: Sequelize.INTEGER
hoursPerWeek: Sequelize.INTEGER
})
})
Project.hasMany('members', Member)
Project.hasMany('members', Member)
Member.belongsTo('project', Project)
Member.belongsTo('project', Project)
var p = new Project({
var p = new Project({
name: 'my awesome project',
name: 'my awesome project',
description: 'foo bar'
description: 'foo bar'
})
})
var m = new Project({
var m = new Project({
name: 'Depold',
name: 'Depold',
firstName: 'Sascha',
firstName: 'Sascha',
hoursPerWeek: 20
hoursPerWeek: 20
})
})
p.save()
p.save()
m.save()
m.save()
m.updateAttributes({m.projectId: p.id})
m.updateAttributes({m.projectId: p.id})
... to be completed ...
... to be completed ...
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment