Git Product home page Git Product logo

website's Introduction

sequelize.org

Sequelize's documentation website

This website is built using Docusaurus 2.

Installation

# install local dependencies using yarn
yarn

# download the sequelize repository (used for including tested code snippets & generating jsdoc)
yarn sync

Local Development

yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Deployment

Using SSH:

USE_SSH=true yarn deploy

Not using SSH:

GIT_USER=<Your GitHub username> yarn deploy

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the gh-pages branch.

website's People

Contributors

0xajinkya avatar adrianvhz avatar amincheloh avatar barraponto avatar boehs avatar brianpeiris avatar ccr-bhurtel avatar chigozie-gerald avatar crazystevenz avatar damms005 avatar dependabot[bot] avatar devharipragaz007 avatar ephys avatar evanrittenhouse avatar farajael avatar filiphavel avatar fzn0x avatar h4dying avatar hjamil-24 avatar itsalb3rt avatar kaimbelic avatar lohart13 avatar luzefiru avatar pocketarc avatar redeemefy avatar renovate[bot] avatar ruyd avatar sdepold avatar tinygvillage avatar wikirik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

website's Issues

Full-Text Search using TSVector

Issue Creation Checklist

[] I have read the contribution guidelines

Issue Description

I'm trying to use the Sequelize.TSVector to implement Full-Text search however there doesn't seem to be any documentation on how to use TSVector or how it is used in conjunction with Op.Match. I've seen various speculations on stack overflow on how it is to be used and I've tried them all with no success. It would be great to get some documentation on how to use TSVector for Full-text search.

What was unclear/insufficient/not covered in the documentation

There is not any documentation.

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

Write here.

Additional context

Add any other context or screenshots about the issue here.

Reorder Migrations Page

Issue Creation Checklist

Issue Description

What was unclear/insufficient/not covered in the documentation

In migrations page how to generate migration

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

In the migrations page there must be Migration Skeleton comes first or right after Creating the first Model (and Migration) and then running migration documentation comes into play because this we must know how to generate migration first then how to run it

Additional context

--

TIME datatype not documented

Hi All,

I'm using Sequelize with MySql and I need to use the datatype TIME in one of mine model.
From the documentation, I know that Sequelize supports only DATA and DATEONLY but I didn't find a way to insert only the time.

Can you suggest me a solution for it?
Thanks.

Best Practice documentation for import (associations)

Awesome job getting to v5!

Possibly add a small example "best practice" of how to completely separate the model files in the documentation

http://docs.sequelizejs.com/manual/models-definition.html > Import

is very close but it does not address how to best put the associations into the separate model files

The examples here assume that you have imported all the models into this one file and then code all the associations after all the models have been imported

http://docs.sequelizejs.com/manual/associations.html

I believe most are using this an example prior to v5
https://codewithhugo.com/using-es6-classes-for-sequelize-4-models/

Explain `joinTableAttributes` versus `include: { attributes }` in the manuals

Issue Description

Currently the joinTableAttributes option is barely mentioned in the manuals (ctrl+f here).

What was unclear/insufficient/not covered in the documentation

What does it do and how it relates to the more known include: { attributes: [ /* ... */ ] } option

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

Just briefly mention it in the manuals and explain its difference, no need for complicated things...

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.

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

  • 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.

reconnect after close by manual

Issue Creation Checklist

Issue Description

What was unclear/insufficient/not covered in the documentation

How can I reconnect the sqlite after the sequelize close.

I read the docs to close the connect. It's working. But how can I reconnect the sqlite by the original object when I do something after closed.

I try to use the ConnectionManager initPools, but It does not work.

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

Write here.

Additional context

Add any other context or screenshots about the issue here.

Set up a watcher for link rot

At least some of the links referenced by the documentation will inevitably die.

We could use something like https://github.com/ephys/puppeteer-crawler to be notified when a link becomes a 404.

I still need to fix some issues with that script first.

We should also not check pages under /v2, /v3, /v4, and /v5 since these versions are not maintained anymore and it would skyrocket the time needed to check.

We probably can do this with a github action that runs once a week.

associations from official documentation example

What was unclear/insufficient/not covered in the documentation

I came from PHP, doctrine world, but now try understand sequlize, I struggle with associations, I tried to follow manual http://docs.sequelizejs.com/manual/associations.html

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

more examples

idea is to have more than one battlefield associated with each game. but only one game to each battlefield, e.g. one-to-many

#game.js
export default (sequelize, DataTypes) => {
    const model = sequelize.define(
        'Game',
        {
            id: {
                // type: DataTypes.UUID,
                type: DataTypes.INTEGER,
                primaryKey: true,
                autoIncrement: true,
            },
        },
        {
            tableName: 'games',
            timestamps: false,
        }
    );

    return model;
};
#battlefield.js
export default (sequelize, DataTypes) => {
    const model = sequelize.define(
        'Battlefield',
        {
            id: {
                // type: DataTypes.UUID,
                type: DataTypes.INTEGER,
                primaryKey: true,
                autoIncrement: true,
            },
            game: {
                // type: DataTypes.UUID,
                type: DataTypes.INTEGER,
                allowNull: false,
            }
        },
        {
            tableName: 'battlefields',
            timestamps: false,
        }
    );

    model.associate = function ({ Game, Battlefield, User }) {
        Game.hasMany(Battlefield, { foreignKey: 'game', sourceKey: 'id' });

        Battlefield.belongsTo(Game, { foreignKey: 'game', targetKey: 'id' });
    }

    return model;
};
#query:
                models.Battlefield.findAll({
                    include: [
                        {
                            model: models.Game,
                            where: {
                                id: gameId,
                            },
                        },
                    ],
                    raw: true,
                })
result: 
Game is not associated to Battlefield!

to overcome it, index.js is like very needed:

import fs from 'fs';
import path from 'path';
import Sequelize from 'sequelize';
import { database as c } from '../../config/config';

const sequelize = new Sequelize(c.database, c.username, c.password, c);

const basename = path.basename(__filename);
const context = fs
    .readdirSync(__dirname)
    .reduce(
        (acc, file) => {
            if ((file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js')) {
                const model = sequelize['import'](path.join(__dirname, file));
                acc[model.name] = model;
            }

            return acc;
        },
        {}
    );

for (const name in context) {
    const model = context[name];

    if (model.associate) {
        model.associate(context);
    }
}

context.sequelize = sequelize;
context.Sequelize = Sequelize;

export default context;

it is unclear from docs, how to initiate models

The manuals should clarify how eager loading works with paranoid

What was unclear/insufficient/not covered in the documentation

The manuals do not make clear what happens when a finder method such as findAll tries to include an associated model which has some softed-deleted instances. Does every instance come in the query? Or only the non-soft-deleted ones?

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

Add a subsection to the manual explaining this behavior.

Misleading aliases in "Multiple associations involving the same models" documentation

Issue Creation Checklist

Issue Description

What was unclear/insufficient/not covered in the documentation

I suspect that Chapter Multiple associations involving the same models contains misleading examples of association aliases:

Team.hasOne(Game, { as: 'HomeTeam', foreignKey: 'homeTeamId' });
Team.hasOne(Game, { as: 'AwayTeam', foreignKey: 'awayTeamId' });
Game.belongsTo(Team);

If I define HomeTeam and AwayTeam aliases, then, for instance, to fetch the team's home game using lazy loading I need to call team.getHomeTeam(). This doesn't make sense to me.

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

To change the aliases to HomeGame and AwayGame:

Team.hasOne(Game, { as: 'HomeGame', foreignKey: 'homeTeamId' });
Team.hasOne(Game, { as: 'AwayGame', foreignKey: 'awayTeamId' });
Game.belongsTo(Team);

The naming schema for junction tables is read as pascal casing by default, not camel casing

Issue Creation Checklist

Issue Description

What was unclear/insufficient/not covered in the documentation

The written documentation and the code examples are inconsistent in the casing of foreign key column names regarding associations. The documentation shows camel casing, while the examples show pascal casing. The examples are correct.

Example 1

On the many-to-many relationships section under Goal, it states:

The junction table that will keep track of the associations will be called ActorMovies, which will contain the foreign keys movieId and actorId.

The example immediately after shows that it creates the MovieId and ActorId foreign keys, which is correct.

Example 2

On the one-to-many relationships section, it states under the Philosophy section:

For example, if one Foo has many Bars (and this way each Bar belongs to one Foo), then the only sensible implementation is to have a fooId column in the Bar table.

The example immediately after shows the CREATE TABLE command creating a pascal-cased foreign key (TeamId).

Example 3

The naming strategies section indicates that:

Without the underscored option, Sequelize would automatically define:

  • A createdAt attribute for each model, pointing to a column named createdAt in each table
  • An updatedAt attribute for each model, pointing to a column named updatedAt in each table
  • A userId attribute in the Task model, pointing to a column named userId in the task table

However, on the last bullet point, a pascal-cased UserId column would be created in the task table.

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

  • The written documentation should correctly mention that the default behavior will create pascal-cased column names for associations

Additional context

I spent quite a while trying to find the problem with creating models with associations when I found this issue: sequelize/sequelize#13330

In my case, Sequelize was by default attempting to insert values for pascal-cased column names that don't exist. My column names are camel-cased.

Add issue / PR template

Just like the title says, we probably also need an issue and PR template in this repo. We can probably copy the one from the main repo and update it a bit

Improve the documentation about migrate workflow

Issue Description

It's unclear about how to create associations in migration files when the models have associations with each other.

What was unclear/insufficient/not covered in the documentation

I read the migrations docs and the code of sequelize express-example.

The docs just explain how to create a model and migration file using sequelize-cli. The thing is when people create models and migration files such as User and Task and define associations like this:

// user.js
// ...
  User.associate = function(models) {
    User.hasMany(models.Task);
  }
// ...
// task.js
// ...
  Task.associate = function(models) {
    // Using additional options like CASCADE etc for demonstration
    // Can also simply do Task.belongsTo(models.User);
    Task.belongsTo(models.User, {
      onDelete: "CASCADE",
      foreignKey: {
        allowNull: false
      }
    });
  }
// ...

Now, the models have associations. But, the migration file DOES NOT have associations. This means even if the UserId is added to the Task model. But in the migration file, the Task table doesn't have UserId at this moment.

Here are the workflow steps I current use:

  1. Create migration and model files using sequelize-cli
  2. Define the model and the associations manually based on my business logic.
  3. Back to modify the generated migration file, add the UserId column to xxx-create-task.js file (This is where I'm not sure and confused. But I saw the express-example use this workflow)

So, what's the correct workflow to create associations in migration files?

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

If I understand correctly, the migration file and the model are a different part. This means we have to keep both in sync manually, sequelize and sequelize-cli will not do it for us automatically.
Another issue is to create the join table, sequelize-cli will not create the join table, right? If so, what's the best way to create this join table migration file?

It's different from the sequelize.sync() API. For testing purposes, this API will create tables with correct associations, add UserId column to the Task table based on the models' associations we defined. Besides, it also create join table for many-to-many association too. It seems this API will keep the model and "migration" sync automatically

Additional context

I found a post about this in medium: https://medium.com/@andrewoons/how-to-define-sequelize-associations-using-migrations-de4333bf75a7

It seems the author uses the same workflow as mine

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.

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

  • 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.

Clarify whether it is OK to fire concurrent queries using the same transaction

Issue Creation Checklist

[x] I have read the contribution guidelines

Issue Description

What was unclear/insufficient/not covered in the documentation

It is popular to write asynchronous code in JavaScript. And because sequelize.query is async and returns a Promise, it can be very tempting to write code like this:

await sequelize.transaction(async (transaction) => {
  await Promise.all([
    sequelize.query(query1, {transaction}),
    sequelize.query(query2, {transaction}),
    /* and more queries ... */
    sequelize.query(queryN, {transaction}),
  ]);
});

However, it is not entirely clear from the documentation whether this is supposed to work. I mean, this might accidentally work if the queries are all very short and quick. But what happens if some queries take longer than others? What if the queries are indirectly/implicitly related (e.g. query2 depending on some changes effected in the database by query1). Does sequelize automatically order the queries (in the order that the sequelize.query() calls were made), even though they look to be fired concurrently? Would the correct functioning depend on how async is implemented in the JavaScript runtime; would it work correctly in node.js but be dangerous in a hypothetical alternative JavaScript runtime that is still conformant to ECMA-262?

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

Explicitly explain whether concurrent queries can work correctly (i.e. the way the programmer might expect), maybe under specific conditions - e.g. no indirect/implicit dependency among the queries.

Document how to create a plugin for other database dialects

Issue Description

What was unclear/insufficient/not covered in the documentation

If a developer is willing to develop support for another dialect for Sequelize, what are the steps to do it?

Additional context

PR sequelize/sequelize#11073 is an example of attempt to add support for a new dialect to Sequelize. However we should have a guide on how to do it, and ideally should offer a way for users to write separate plugins to do this, so that they don't have to go over the work of a big PR.

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.

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

  • 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.

Better docs for generating models

I want to make simple table scheme, includes int and datetime types.

However, I just read whole documentation, but couldn't find any helpful information about this issue.

$ sequelize model:generate --name Notes --attributes id:int,text:content,createdAt:datetime,updatedAt:datetime

ERROR: Attribute 'id:int' cannot be parsed: Unknown type 'int'

Fortunately, cli generates some default fields:

$ sequelize model:generate --name Notes --attributes text:content
// results
'use strict';
module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Notes', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      content: {
        type: Sequelize.TEXT
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Notes');
  }
};

But it's quite annoying that it's really important thing but there no mentioned about this.

I just found exact type name for "Int" and "Datetime" in attributes from this document: https://github.com/sequelize/cli/blob/master/docs/FAQ.md

$ sequelize model:create --name User --attributes name:string,state:boolean,birth:date,card:integer

Seriously, this information must be added in the document. Or, just put some more helpful information on displaying error, not just telling me you typed wrong type.

Dialect: sqlite
Database version: 3.9.2
Sequelize CLI version: 5.2.0
Sequelize version: 4.41.0

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Branch Automerge

These updates await pending status checks before automerging. Click on a checkbox to abort the branch automerge, and create a PR instead.

  • meta: update docusaurus monorepo to v3.4.0 (@docusaurus/core, @docusaurus/module-type-aliases, @docusaurus/preset-classic, @docusaurus/remark-plugin-npm2yarn, @docusaurus/theme-mermaid, @docusaurus/tsconfig)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/autoupdate.yml
  • actions/create-github-app-token v1
  • sequelize/pr-auto-update-and-handle-conflicts 1.0.1@257ac5f68859672393e3320495164251140bd801
.github/workflows/draft.yml
  • actions/checkout v4
  • actions/setup-node v4
  • juliangruber/read-file-action v1
  • peter-evans/create-or-update-comment v4
.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @docusaurus/core 3.2.1
  • @docusaurus/preset-classic 3.2.1
  • @docusaurus/remark-plugin-npm2yarn ^3.2.1
  • @docusaurus/theme-mermaid 3.2.1
  • @mdx-js/react 3.0.0
  • @react-hookz/web 24.0.4
  • @sequelize/utils 7.0.0-alpha.41
  • clsx 2.1.1
  • docusaurus-plugin-sass 0.2.5
  • prism-react-renderer 2.3.1
  • raw-loader 4.0.2
  • react 18.3.1
  • react-dom 18.3.1
  • react-feather 2.0.10
  • react-responsive-carousel 3.2.23
  • sass 1.77.8
  • @docusaurus/module-type-aliases 3.2.1
  • @docusaurus/tsconfig 3.2.1
  • @ephys/eslint-config-typescript 20.1.4
  • @rushstack/eslint-patch 1.10.3
  • concurrently 8.2.2
  • eslint 8.57.0
  • eslint-plugin-jsx-a11y 6.8.0
  • eslint-plugin-mdx 1.17.1
  • eslint-plugin-react 7.35.0
  • eslint-plugin-react-hooks 4.6.2
  • husky 9.1.1
  • lint-staged 15.2.7
  • prettier 3.2.5
  • typescript 5.5.3

  • Check this box to trigger a request for Renovate to run again on this repository

[Docs] Make landing page easier to locate, deprecate older docs site

What was unclear/insufficient/not covered in the documentation

When I first came across the docs and went to Getting Started I was a bit confused, as I thought maybe that was the top-level document that I had landed on(index) originally but it wasn't. To get back to that, it requires you to click the top-left logo or manually adjust the url. Minor UX thing.

As a new user, I also came across these older docs last updated in 2016. It's not immediately clear that they're out of date either, if that's something under this projects control, perhaps it should be pulled down or given some notice to the maintained docs.

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

From my earlier report

What are you suggesting though? That having an Index entry above Getting Started would be better?

Based on context, perhaps a good title for it on the sidebar would be "About" / "About Sequelize"? Followed by some header for the section after Quick example, maybe.. "Jump to page" or something else descriptive of what purpose that section of page previews is serving.

Post-publish tasks

Documentation about SSL connection

Issue Description

What was unclear/insufficient/not covered in the documentation

SSL connection is not addressed in the documentation

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

Instance Constructor could specify all the parameters it actually takes, and if it is just a translation then point to that resource valid options.

Additional context

This Issue saved me as this other one. The last one is a great example of how to add a section to the docs.

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • I don't know.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ

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

  • 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.

Standardizing/documenting a way to create plugins for Sequelize

Since sequelize is relaying on hooks to comunicate with plugins, shouldn't be better to include a method so we can pass a sequelize instance to plugins?

I would propose a similar socket.io and express.js approach...

API Proposal

Specs for Sequelize.prototype.plugin

1 - .plugin method should communicate with plugins by passing to the plugin's function: sequelize instance as 1st argument, and options object as 2nd argument.
1.1 - If first argument is a function, it should only call it with sequelize instance.
1.2 - For the laziest and KISS fans, if a string is provided instead as .plugin's first argument, .plugin method should use require internally.
1.2.1 - We should be able to require relational paths
1.2.1.1 - If an wild card exists, it should search for .js files and require them all recursively.
1.2.2 - We should be able to require node modules
1.3 - If first argument is an array, it should call it self recursively with each value
2 - Options handling
2.1 - Second argument of .plugin should be optional and be passed to plugin always as an object
2.2 - If plugin's function has the key defaultOptions defined as an object, .plugin should extend options, if provided, from it.
3 - .plugin should throw an error if something went wrong.
4 - .plugin should return sequelize instance always for chain proposes.

Specs for Sequelize.plugin

1 - Should proxy into Sequelize.prototype.plugin by passing args context within afterInit hook

Core Implementation Example
Sequelize.plugin = function ( plugin, options ) {
  return this.addHook( 'onInit', function ( sequelize ) {
    sequelize.plugin( plugin, options );
  });
};

Plugging Examples

/*
 *  Plugging into Sequelize Class ( they will be applied on all future Sequelize instances )
 */
Sequelize.plugin( 'sequelize-cache-redis' );

/*
 *  Plugging into Sequelize instance (won't be applied on other Sequelize instances )
 */
var sequelize = new Sequelize( /* ... */ );

sequelize.plugin( 'sequelize-cache-redis' );

/*
 *  Plugging multiple plugins into a Sequelize Class by chaining
 */
Sequelize
  .plugin( 'sequelize-cache-redis' )
  .plugin( 'sequelize-tree' );

/*
 *  Plugging multiple plugins into a Sequelize Class by an array with names
 */
Sequelize
  .plugin([ 'sequelize-cache-redis', 'sequelize-tree' ]);

/*
 *  Plugging into a Sequelize Class from a folder of plugins
 */
Sequelize.plugin( './models/plugins/*' );

/*
 *  Plugging into a Sequelize Class providing options
 */
Sequelize.plugin( 'plugin-name', { foo: 'bars' } );

/*
 *  Plugging the same plugin into different Sequelize instances with different options
 */
var localRedisClient, sharedRedisClient;

var mysql = new Sequelize( /* mysql config */ );
var sqlite = new Sequelize( /* local sqlite config */ );

mysql.plugin( 'sequelize-cache-redis', { redis: sharedRedisClient });
sqlite.plugin( 'sequelize-cache-redis', { redis: localRedisClient });

Plugin Examples

/*
 *  Plugin skeleton example
 */
module.exports = function ( sequelize, options ) {
  // ...
};

// Default options definition
module.exports.defaultOptions = {
  somePluginOption: false,
};
/*
 *  Cache Plugin example
 */
module.exports = function ( sequelize, options ) {
  if( ! options.redis ) return;

  sequelize.addHook( 'afterDefine', function ( Model ) {
    if( ! Model.options.cache ) return;

    Model.addHook( 'beforeFind', function ( queryOptions ) {
      // ...
    });

    Model.addHook( 'afterFind', function ( queryOptions ) {
      // ...
    });
  });
};

// Default options definition
module.exports.defaultOptions = {
  redis: false,
};

Opinions and suggestions?
@overlookmotel @mickhansen @janmeier

List of broken URLs

Just ran my script on the latest preview, here is the complete list of broken internal URLs:

https://sequelize-site.netlify.app/v6/index.html
https://sequelize-site.netlify.app/v6/manual/getting-started.html
https://sequelize-site.netlify.app/v6/manual/whos-using.html
https://sequelize-site.netlify.app/v6/class/src/model.js~Model.html
https://sequelize-site.netlify.app/v6/function/index.html
https://sequelize-site.netlify.app/api/v6/source.html
https://sequelize-site.netlify.app/v3/api/sequelize/sequelize
https://sequelize-site.netlify.app/v3/api/sequelize/transaction
https://sequelize-site.netlify.app/v3/api/sequelize/deferrable
https://sequelize-site.netlify.app/v3/api/sequelize/instance
https://sequelize-site.netlify.app/v3/api/sequelize/association
https://sequelize-site.netlify.app/v3/api/sequelize/errors
https://sequelize-site.netlify.app/v3/api/sequelize/queryinterface
https://sequelize-site.netlify.app/v3/api/sequelize/datatypes
https://sequelize-site.netlify.app/v3/api/sequelize/hooks
https://sequelize-site.netlify.app/v3/api/sequelize/model
https://sequelize-site.netlify.app/v2/sequelize
https://sequelize-site.netlify.app/v2/utils
https://sequelize-site.netlify.app/v2/promise
https://sequelize-site.netlify.app/v2/transaction
https://sequelize-site.netlify.app/v2/instance
https://sequelize-site.netlify.app/v2/errors
https://sequelize-site.netlify.app/v2/queryinterface
https://sequelize-site.netlify.app/v2/migrator
https://sequelize-site.netlify.app/v2/datatypes
https://sequelize-site.netlify.app/v2/hooks
https://sequelize-site.netlify.app/v2/model
https://sequelize-site.netlify.app/v2/irc://irc.freenode.net/
https://sequelize-site.netlify.app/api/v6/class/src/model.js~Model.html
https://sequelize-site.netlify.app/api/v6/class/src/errors/connection/connection-acquire-timeout-error.js~ConnectionAcquireTimeoutError.html
https://sequelize-site.netlify.app/api/v6/file/src/sequelize.js.html
https://sequelize-site.netlify.app/master/manual/model-basics.html
https://sequelize-site.netlify.app/api/v6/file/src/data-types.js.html
https://sequelize-site.netlify.app/api/v6/file/src/deferrable.js.html
https://sequelize-site.netlify.app/api/v6/file/src/index-hints.js.html
https://sequelize-site.netlify.app/api/v6/file/src/query-types.js.html
https://sequelize-site.netlify.app/api/v6/file/src/table-hints.js.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/validation-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/abstract/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/transaction.js.html
https://sequelize-site.netlify.app/api/v6/file/src/associations/base.js.html
https://sequelize-site.netlify.app/api/v6/file/src/associations/belongs-to-many.js.html
https://sequelize-site.netlify.app/api/v6/file/src/associations/belongs-to.js.html
https://sequelize-site.netlify.app/api/v6/file/src/associations/has-many.js.html
https://sequelize-site.netlify.app/api/v6/file/src/associations/has-one.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/db2/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/mssql/async-queue.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/mssql/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/mysql/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/postgres/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/snowflake/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/dialects/sqlite/query-interface.js.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/aggregate-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/association-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/base-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/bulk-record-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/database-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/eager-loading-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/empty-result-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/instance-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/optimistic-lock-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/query-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/sequelize-scope-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/access-denied-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/connection-acquire-timeout-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/connection-refused-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/connection-timed-out-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/host-not-found-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/host-not-reachable-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/connection/invalid-connection-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/database/exclusion-constraint-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/database/foreign-key-constraint-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/database/timeout-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/database/unknown-constraint-error.ts.html
https://sequelize-site.netlify.app/api/v6/file/src/errors/validation/unique-constraint-error.ts.html
https://sequelize-site.netlify.app/v3/docs/api/datatypes
https://sequelize-site.netlify.app/v3/docs/models-definition/transactions/
https://sequelize-site.netlify.app/v3/docs/scopes/associations/
https://sequelize-site.netlify.app/v3/docs/associations/scopes
https://sequelize-site.netlify.app/api/hooks
https://sequelize-site.netlify.app/v3/api/model/sequelize
https://sequelize-site.netlify.app/v3/api/model/transaction
https://sequelize-site.netlify.app/v3/api/model/model
https://sequelize-site.netlify.app/v3/api/model/instance
https://sequelize-site.netlify.app/v3/api/instance/sequelize
https://sequelize-site.netlify.app/v3/api/instance/model
https://sequelize-site.netlify.app/v3/api/instance/instancevalidator
https://sequelize-site.netlify.app/v3/api/instance/instance
https://sequelize-site.netlify.app/v3/sequelize/
https://sequelize-site.netlify.app/v3/model/
https://sequelize-site.netlify.app/v3/instance/
https://sequelize-site.netlify.app/v3/api/
https://sequelize-site.netlify.app/v3/api/has-one/
https://sequelize-site.netlify.app/v3/api/has-many/
https://sequelize-site.netlify.app/v3/api/belongs-to-many/
https://sequelize-site.netlify.app/v3/hooks/
https://sequelize-site.netlify.app/v3/transaction/
https://sequelize-site.netlify.app/v3/datatypes/
https://sequelize-site.netlify.app/v3/deferrable/
https://sequelize-site.netlify.app/v3/errors/
https://sequelize-site.netlify.app/v3/api/belongs-to/
https://sequelize-site.netlify.app/v3/api/hooks/sequelize
https://sequelize-site.netlify.app/v2//docs/latest/migrations
https://sequelize-site.netlify.app/v2//docs/latest/models
https://sequelize-site.netlify.app/v2//docs/latest/associations
https://sequelize-site.netlify.app/v2//docs/latest/usage
https://sequelize-site.netlify.app/v2//docs/latest/misc
https://sequelize-site.netlify.app/v2/instancevalidator
https://sequelize-site.netlify.app/api/v7/interfaces/transaction
https://sequelize-site.netlify.app/api/v6/manual/..class/src/model.js~Model.html
https://sequelize-site.netlify.app/api/v6/manual/polymorphism-and-scopes.html
https://sequelize-site.netlify.app/api/v6/file/src/utils.js.html

List of things that need to be added to the documentation

Instead of creating many issues, I'll keep a list of things we should add to the documentation here:

Associations

Eager-loading

Migrations

  • Emphasize that sync is unsafe in production
  • Document how to use raw SQL (sequelize.query)
  • Document how to use .sql migration files
  • Document queryInterface

Main tasks to complete before initial publish

This issue tracks our progress with the development of the new website.
It used to be in sequelize/sequelize#13914, but it makes more sense to move it here.

Associations count<assoc>s functions

What was unclear/insufficient/not covered in the documentation

Just tried BelongsToMany association roles<->permissions countPermissions(options) method of roles model with where in options and it worked as expected! Is it just undocumented or may broke in future?

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

http://docs.sequelizejs.com/manual/associations.html#belongs-to-many-associations in line with text "This will add methods getUsers, setUsers, addUser,addUsers to Project, and getProjects, setProjects, addProject, and addProjects to User." add count* functions examples like "countProjects and countUsers".

Add search bar

Docusaurus supports searching through the documentation thanks to Agolia https://docusaurus.io/docs/search. Let's add that to our site :)

We already did talk about this in the initial PR but search wasn't a blocking point for the initial release because the previous esdoc search only searched through the API reference (which is still there)

Provide guidance on how to avoid connection issues with Amazon infrastructure (TimeoutError: ResourceRequest timed out)

There is a very very long issue (#7884) about issues when connecting to Amazon infrastructure.

Once, in a comment, @sushantdhiman suggested writing some documentation guidance on how to resolve this issue.

So it would be great to have somewhere in our docs some instructions to help people overcome this.

I believe all the necessary information can be found in sequelize/sequelize#7884, but it is certainly very messy right now.

Support windows authentication for MSSQL Sever

Is your feature request related to a problem? Please describe.

Current sequelize module doesn't support sql server windows authentication which is preventing the usage in several environments.

Describe the solution you'd like
Option to use Windows Authentication in some environments

Why should this be in Sequelize
Short explanation why this should be part of Sequelize rather than a separate package.

Describe alternatives you've considered
Tried the module sequelize-msnodesqlv8 but it is not maintained anymore or works for me

Sequelize using SQLcipher to encrypt DB

Issue Description

I am trying to encrypt the database using SQLCipher. In the Sequelize documentation it says that it is possible to do: "Supports SQLCipher encryption for SQLite." But in the documentation I can't find the steps of how to do. I am trying to follow the following example found in Stackoverflow but I get the error: "SQLITE_NOTAD"

StackOverflow / Slack attempts

related case:
https://stackoverflow.com/questions/33363075/how-to-make-encrypted-sqlite3-database-with-nodejs-in-windows-platform

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): SQLCipher on Sequelize
  • I don't know.

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

  • 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.

Typescript CreationAttributes are always being marked as optional with strictNullChecks disabled

Issue Creation Checklist

Bug Description

Typescript CreationAttributes are being marked as optional regardless of actually marking them as so. When creating a model typescript does not complain about some required parameters that are missing because of this.

Example

import { DataTypes, Model, Optional, Sequelize } from "sequelize"

interface Attributes {
    id: string
    name: string
    height: number
}

type CreationAttributes = Optional<Attributes, "id">

export default class Person extends Model<Attributes, CreationAttributes> implements Attributes {
    public id!: string
    public name!: string
    public height!: number

    public static initialize(sequelize: Sequelize) {
        this.init({
            id: {
                type: DataTypes.UUID,
                defaultValue: DataTypes.UUIDV4,
                field: "ID",
                primaryKey: true,
                allowNull: false,
            },
            name: {
                type: DataTypes.STRING,
                field: "Name",
                allowNull: false,
            },
            height: {
                type: DataTypes.NUMBER,
                field: "Height",
                allowNull: false,
            }
        }, {
            sequelize: sequelize,
            tableName: "Person"
        })
    }
}

What do you expect to happen?

It should throw a typescript error if Person.name and Person.height are not provided when creating a Person.

What is actually happening?

Typescript thinks name is optional even though it's being marked as required.
Screen Shot 2022-04-06 at 3 09 48 PM

Typescript does not complain when required fields are omitted.
Screen Shot 2022-04-06 at 3 10 09 PM

Environment

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

  • No, I don't have the time, although I believe I could do it if I had the time...

misleading documentation on "type" parameter

https://github.com/sequelize/sequelize/blob/ff1c97cd9264d50c1d779b31a8d38dd4182ddfaa/lib/sequelize.js#L427

This documentation indicates that ANY time the "type" parameter is specified, the returned result is the row, without the counts. However, looking at the actual code:

https://github.com/sequelize/sequelize/blob/ff1c97cd9264d50c1d779b31a8d38dd4182ddfaa/lib/dialects/postgres/query.js#L261

This is NOT the case with insert/update/raw. This should either be adjusted in the documentation to mention excluded cases, or should be updated in the Query to return the expected result for these other cases. I vote the latter personally, as it provides more code flexibility in general - but I do understand that would be a breaking change, since people would have had to work around this issue by now.

It should also be noted, that this was working properly in sequelize v3. When I started migrating to v4, this issue presented itself. Here's the example query I had to modify as a result:

   return sequelize.query(sql, {
        type: models.Sequelize.QueryTypes.UPDATE,
        replacements: {
          jobId,
          status: metricStatuses.PROCESSING,
          workerMeta: JSON.stringify(workerMeta),
        },
        raw: true,
      })
      .then(_.first) ////////// this shouldn't be needed, docs say setting the type avoids this
      .then(_.first);

TypeScript example from documentation fails with "SequelizeDatabaseError: Duplicate column name 'UserId'"

When executing the "Example of a minimal TypeScript project" from http://docs.sequelizejs.com/manual/typescript.html, running sequelize.sync() fails with the following error:

Executing (default): CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER UNSIGNED auto_increment , `name` VARCHAR(128) NOT NULL, `preferredName` VARCHAR(128), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `users`
Executing (default): CREATE TABLE IF NOT EXISTS `projects` (`id` INTEGER UNSIGNED auto_increment , `ownerId` INTEGER UNSIGNED NOT NULL, `name` VARCHAR(128) NOT NULL, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`ownerId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `projects`
Executing (default): CREATE TABLE IF NOT EXISTS `address` (`id` INTEGER NOT NULL auto_increment , `userId` INTEGER UNSIGNED, `address` VARCHAR(128) NOT NULL, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `UserId` INTEGER UNSIGNED, PRIMARY KEY (`id`), FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE) ENGINE=InnoDB;
(node:8856) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Duplicate column name 'UserId'

As you can see, the address table first creates a userId key and then yet another UserId key (which it then tries to use as a foreign key).

I believe this is in line which what is reported in sequelize/sequelize#3035 and sequelize/sequelize#9328 and I fixed it by replacing

Address.belongsTo(User, { targetKey: "id" });
User.hasOne(Address, { sourceKey: "id" });

with

Address.belongsTo(User, { targetKey: "id", foreignKey: "userId" });
User.hasOne(Address, { sourceKey: "id", foreignKey: "userId" });

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

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.
  • 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?

  • 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.

Add some more packages to the docs resources section

Issue Description

What was unclear/insufficient/not covered in the documentation

I found three repositories that look useful to be included in the resources section of the docs:

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

Just add them

Additional context

I found one of them here: 7197#comment

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.

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

  • 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.

Block indexing of unmaintained versions

I personally still end up on the documentation for Sequelize v5 whenever I try to look up something.

I think we should noindex everything in /v1 -> /v5, + /main & /master

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.