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 96bc06cc
authored
Aug 08, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using the inflection library; replace them by npm later
1 parent
e71addc8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
src/SequelizeHelper.js
test/SequelizeHelperTest.js
src/SequelizeHelper.js
View file @
96bc06c
...
@@ -18,7 +18,7 @@ SequelizeHelper = {
...
@@ -18,7 +18,7 @@ SequelizeHelper = {
},
},
asTableIdentifier
:
function
(
name
)
{
asTableIdentifier
:
function
(
name
)
{
return
name
.
toLowerCase
().
replace
(
/s$/
,
""
)
+
"Id"
return
SequelizeHelper
.
Inflection
.
singularize
(
name
.
toLowerCase
()
)
+
"Id"
},
},
addPrefix
:
function
(
prefix
,
string
)
{
addPrefix
:
function
(
prefix
,
string
)
{
...
@@ -26,7 +26,7 @@ SequelizeHelper = {
...
@@ -26,7 +26,7 @@ SequelizeHelper = {
},
},
asTableName
:
function
(
name
)
{
asTableName
:
function
(
name
)
{
return
name
+
"s"
return
SequelizeHelper
.
Inflection
.
pluralize
(
name
)
},
},
asSqlDate
:
function
(
date
)
{
asSqlDate
:
function
(
date
)
{
...
@@ -171,5 +171,7 @@ SequelizeHelper = {
...
@@ -171,5 +171,7 @@ SequelizeHelper = {
arr2
.
forEach
(
function
(
e
)
{
result
.
push
(
e
)
})
arr2
.
forEach
(
function
(
e
)
{
result
.
push
(
e
)
})
return
result
return
result
}
}
}
},
Inflection
:
require
(
__dirname
+
"/../lib/inflection/inflection"
)
}
}
\ No newline at end of file
test/SequelizeHelperTest.js
View file @
96bc06c
...
@@ -18,9 +18,14 @@ module.exports = {
...
@@ -18,9 +18,14 @@ module.exports = {
},
},
'SQL: asTableIdentifier'
:
function
(
assert
)
{
'SQL: asTableIdentifier'
:
function
(
assert
)
{
assert
.
equal
(
h
.
SQL
.
asTableIdentifier
(
'Users'
),
'userId'
)
assert
.
equal
(
h
.
SQL
.
asTableIdentifier
(
'Users'
),
'userId'
)
assert
.
equal
(
h
.
SQL
.
asTableIdentifier
(
'Children'
),
'childId'
)
assert
.
equal
(
h
.
SQL
.
asTableIdentifier
(
'Children'
),
'childId'
)
assert
.
equal
(
h
.
SQL
.
asTableIdentifier
(
'Mice'
),
'mouseId'
)
},
},
'SQL: asTableName'
:
function
(
assert
)
{
'SQL: asTableName'
:
function
(
assert
)
{
assert
.
equal
(
h
.
SQL
.
asTableName
(
'User'
),
'Users'
)
assert
.
equal
(
h
.
SQL
.
asTableName
(
'User'
),
'Users'
)
assert
.
equal
(
h
.
SQL
.
asTableName
(
'Child'
),
'Children'
)
assert
.
equal
(
h
.
SQL
.
asTableName
(
'Mouse'
),
'Mice'
)
},
},
'SQL: asSqlDate'
:
function
(
assert
)
{
'SQL: asSqlDate'
:
function
(
assert
)
{
var
d
=
new
Date
(
Date
.
parse
(
"Tue, 1 Jan 2000 00:00:00 GMT"
))
var
d
=
new
Date
(
Date
.
parse
(
"Tue, 1 Jan 2000 00:00:00 GMT"
))
...
@@ -93,5 +98,8 @@ module.exports = {
...
@@ -93,5 +98,8 @@ module.exports = {
assert
.
eql
(
h
.
Hash
.
merge
(
src
,
target
),
{
a
:
1
,
b
:
3
,
c
:
3
})
assert
.
eql
(
h
.
Hash
.
merge
(
src
,
target
),
{
a
:
1
,
b
:
3
,
c
:
3
})
assert
.
eql
(
h
.
Hash
.
merge
(
src
,
target
,
true
),
{
a
:
1
,
b
:
2
,
c
:
3
})
assert
.
eql
(
h
.
Hash
.
merge
(
src
,
target
,
true
),
{
a
:
1
,
b
:
2
,
c
:
3
})
},
'Inflection: should be available'
:
function
(
assert
)
{
assert
.
isDefined
(
h
.
Inflection
)
}
}
}
}
\ 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