不要怂,就是干,撸起袖子干!

Commit bf37e532 by Sascha Depold

more documentation

1 parent 1d8a6f75
...@@ -26,12 +26,13 @@ app.configure('production', function(){ ...@@ -26,12 +26,13 @@ app.configure('production', function(){
// Routes // Routes
app.get("/background", function(req, res) { app.get("/background", function(req, res) {
require("fs").readdir(__dirname + "/public/images/", function(err, files) { var bgFolder = __dirname + "/public/images/backgrounds/"
require("fs").readdir(bgFolder, function(err, files) {
if(err) sys.log(err) if(err) sys.log(err)
else { else {
if(files[0] == ".DS_Store") files.shift() if(files[0] == ".DS_Store") files.shift()
var i = Math.round(Math.random() * (files.length - 1)) var i = Math.round(Math.random() * (files.length - 1))
res.sendfile(__dirname + "/public/images/" + files[i]) res.sendfile(bgFolder + files[i])
} }
}) })
}) })
......
Sequelize.STRING ===> VARCHAR(255)
Sequelize.TEXT ===> TEXT
Sequelize.INTEGER ===> INT
Sequelize.DATE ===> DATETIME
Sequelize.BOOLEAN ===> TINYINT(1)
\ No newline at end of file
// in your server file - e.g. app.js
var Project = sequelize.import(__dirname + "/path/to/models/project")
// /path/to/models/project.js
// as you might notice, the DataTypes are the very same as explained above
module.exports = function(sequelize, DataTypes) {
return sequelize.define("Project", {
name: DataTypes.STRING,
description: DataTypes.TEXT
})
}
\ No newline at end of file
...@@ -13,11 +13,10 @@ To define mappings between a class and a table, use the define method (Stop tell ...@@ -13,11 +13,10 @@ To define mappings between a class and a table, use the define method (Stop tell
Sequelize currently supports the following datatypes: Sequelize currently supports the following datatypes:
<pre><%= partial("code/usage/basic-mapping-2.ejs") %></pre> <pre><%= partial("code/usage/data-types.ejs") %></pre>
You can also store your model definitions in a single file using the import method: You can also store your model definitions in a single file using the import method:
<pre><%- koala(".js", partial("code/usage/basic-mapping-3.ejs")) %></pre> <pre><%- koala(".js", partial("code/usage/import.ejs")) %></pre>
Choose the name of the exported function the way you want. It doesn't matter at all. You can also specify multiple The returned object is exactly the same as defined in the imported file's function.
models in one file. The import method will return a hash, which stores the result of sequelize.define under the key <i>Project</i>. \ No newline at end of file
\ No newline at end of file
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</div> </div>
</div> </div>
<a href="http://github.com/sdepold/sequelize" id="forkBadge"> <a href="http://github.com/sdepold/sequelize" id="forkBadge">
<img src="http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" id="ribbon" alt="Fork me on GitHub"> <img src="/images/forkme_right_white_ffffff.png" id="ribbon" alt="Fork me on GitHub">
</a> </a>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!