Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Adding all possible model settings to template files #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions templates/attribute.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* e.g. `sails generate model foo attrName`
*
*/
%>
<%if (lang === 'js') {%> <%= name %> : { type: '<%= type %>' }
<%} else if (lang === 'coffee'){ %> <%=name%>:
type: '<%= type %>'
<%}%>
%><% if (lang === 'js') { %> <%= name %>: {
type: '<%= type %>'
}<% } else if (lang === 'coffee') { %>
<%= name %>:
type: '<%= type %>'<% } %>
96 changes: 83 additions & 13 deletions templates/model.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%/**
<%
/**
* Boilerplate model
*
* This is the template used when generating models via the CLI
Expand All @@ -8,23 +9,92 @@
%><% if (lang === 'js') { %>/**
* <%= filename %>
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!/documentation/concepts/ORM/Models.html
* @docs http://sailsjs.org/#!/documentation/concepts/ORM/Models.html
*/

module.exports = {
// Toggle the automatic definition of a createdAt attribute.
// autoCreatedAt: false,

// Toggle the automatic definition of a updatedAt attribute.
// autoUpdatedAt: false,

// Toggle the automatic definition of a primary key. If you turn it off, make
// sure you define some attribute as your PK.
// autoPK: false,

// The lowercase unique key for this model, e.g. user.
// identity: 'customidentityhere',

// The global name by which you can access your model (if the globalization of
// models is enabled).
// globalId: 'CustomGlobalId',

attributes: {
// Controls whether/how Sails will attempt to automatically rebuild the
// tables/collections/sets/etc. in your schema.
// Possible values:
// - safe: never auto-migrate my database(s). I will do it myself (by hand)
// - alter: auto-migrate, but attempt to keep my existing data (experimental)
// - drop: wipe/drop ALL my data and rebuild models every time I lift Sails
// migrate: 'safe',

// A flag to toggle schemaless or schema mode in databases that support
// schemaless data structures.
// schema: true,

// Define which connection queries will be run on.
// connection: 'specify-a-connection-here',

// Define a custom table name to be used by model queries. Useful to work with
// legacy databases.
// tableName: 'custom_table_name_here',

// The most important configuration: your model attributes.
<% if (attributes.length > 0) { %> attributes: {
<%= attributes %>
}
}<% } else { %> attributes: {}<% } %>
};
<%} else if (lang === 'coffee'){ %> # <%= filename %>
<%} else if (lang === 'coffee') { %>
# <%= filename %>
#
# @description :: TODO: You might write a short summary of how this model works and what it represents here.
# @docs :: http://sailsjs.org/#!/documentation/concepts/ORM/Models.html

# @docs http://sailsjs.org/#!/documentation/concepts/ORM/Models.html
module.exports =
# Toggle the automatic definition of a createdAt attribute.
# autoCreatedAt: false

<%if (attributes.length > 0){%> attributes:
<%= attributes %>
<%} else{ %> attributes: {}<%}%><%}%>
# toggle the automatic definition of a updatedAt attribute.
# autoUpdatedAt: false

# Toggle the automatic definition of a primary key. If you turn it off, make
# sure you define some attribute as your PK.
# autoPK: false

# The lowercase unique key for this model, e.g. user.
# identity: 'customidentityhere'

# The global name by which you can access your model (if the globalization of
# models is enabled).
# globalId: 'CustomGlobalId'

# Controls whether/how Sails will attempt to automatically rebuild the
# tables/collections/sets/etc. in your schema.
# Possible values:
# - safe: never auto-migrate my database(s). I will do it myself (by hand)
# - alter: auto-migrate, but attempt to keep my existing data (experimental)
# - drop: wipe/drop ALL my data and rebuild models every time I lift Sails
# migrate: 'safe'

# A flag to toggle schemaless or schema mode in databases that support
# schemaless data structures.
# schema: true

# Define which connection queries will be run on.
# connection: 'specify-a-connection-here'

# Define a custom table name to be used by model queries. Useful to work with
# legacy databases.
# tableName: 'custom_table_name_here'

# The most important configuration: your model attributes.
<%if (attributes.length > 0) { %> attributes:
<%= attributes %>
<%} else { %> attributes: {}<% } %><% } %>