https://nodejs.org/en/download/
npm install sails -g
We recommend using an "Empty" project, but you can use "Webapp", too
sails new projectmanage
npm install sails generate forestay
sails generate forestay user
sails generate forestay usergroup
sails generate forestay project
Your models are located at api/models
and can be modified with Forestay features.
node app.js
Navigate around. You'll quickly realize that there's nothing there.
attributes: {
name: {
type: "string",
required: true
},
email: {
type: "string",
required: true
},
}
These attributes will now appear when you add new users when you go to /user/create
attributes: {
name: {
type: "string",
description: "The project name",
required: true
},
}
attributes: {
name: {
type: "string",
description: "The project name",
required: true
},
}
Let's add a one-to-many relationship between users and usergroups inside the attributes
section of api/models/Usergroup.js
userGroups: {
model:"Usergroup",
meta: {
forestay: {
populateBy: "name", // This is the attribute value that it uses to populate your UI
filterable: true, // you will now be able to filter users by usergroups
label: "User Group", // This is what label will be shown to the user
description: "The user group this user is assigned to", // This will display as a help description on create/update
}
}
},
Now navigate to /userGroup/ and create a couple user groups like "Admin" or "Project Manager"
You can now associate users to usergroups by creating new users.