website icon indicating copy to clipboard operation
website copied to clipboard

Docs needs a section for example code on generated models from the CLI

Open bterone opened this issue 4 years ago • 3 comments

Issue Description

What was unclear/insufficient/not covered in the documentation

There is no section covering the proper usage after generating a model using the sequelize-cli. It will be useful for users to have a section covering how to use the generated files in the CLI from the documentation.

If possible: Provide some suggestion on how we can enhance the docs

✅: Possibly adding a section under Migrations / Creating the first Model (and Migration) on usage of how to use the models/index.js and models/user.js generated in an actual use case.

// Require way
const db = require("./models/index");
const User = require("./models/user");

// Import way
import db from "./models/index";
import User from "./models/user";

const user = User(db.sequelize, db.Sequelize.DataTypes)

const jane = user.build({
  firstName: "Jane",
  lastName: "Doe",
  email: "[email protected]"
});

console.log(jane.toJSON())

✅: Another approach could be us moving file usage to its own section. Like a setup guide so we can move out Project bootstrapping and Project bootstrapping / Configuration from the Migrations page. This ensures we can have a section dedicated to project setup via the CLI and reference other relevant parts of the documentation from there.

If there are any other recommendations, I'm happy to hear any suggestions 😄

Additional context

It's just odd to see project setup instructions via the CLI hidden away under migrations, considering how important the CLI is for proper usage in projects. Screen Shot 2021-06-19 at 9 25 34 AM

Issue Template Checklist

Is this issue dialect-specific?

  • [ ] No. This issue is relevant to Sequelize as a whole.
  • [x] Yes. This issue only applies to the following dialect(s): Migration-section in the documentation.
  • [ ] I don't know.

Would you be willing to resolve this issue by submitting a Pull Request?

  • [x] Yes, I have the time and I know how to start.
  • [ ] Yes, I have the time but I don't know how to start, I would need guidance.
  • [ ] No, I don't have the time, although I believe I could do it if I had the time...
  • [ ] No, I don't have the time and I wouldn't even know how to start.

bterone avatar Jun 19 '21 02:06 bterone

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

github-actions[bot] avatar Oct 27 '21 18:10 github-actions[bot]

Bump

bterone avatar Oct 28 '21 03:10 bterone

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

github-actions[bot] avatar Nov 05 '21 00:11 github-actions[bot]