Coder Social home page Coder Social logo

Comments (7)

sdepold avatar sdepold commented on May 14, 2024

Yep you are right. I've chosen NOT NULL because it doesn't make any sense to have a boolean value with 3 states ^_^ The problem is, that you currently can't set default values. But I really have to implement that. If done, you will be able to just set the default for the boolean values. For now I would recommend to not allow NULL but to set a default :)

from sequelize.

assertchris avatar assertchris commented on May 14, 2024

I tried NULL with a default but couldn't get it to work. It created the table with the correct defaults but tried to set the booleans to NULL on insert/update... :/

from sequelize.

sdepold avatar sdepold commented on May 14, 2024

hey I just implemented default values and the possibility declare a field as non-null/null field.

please let me know if this works nicely :) I will change the documentation soon, but for now:

s.define("foobar", {
aBoolean: { type: Sequelize.BOOLEAN, allowNull: false, default: false },
aString: Sequelize.STRING
})

this will define the field aBoolean with the default of false and which is not allowed to save a null value

furthermore you will get a field aString which is just the normal varchar string :)

from sequelize.

sdepold avatar sdepold commented on May 14, 2024

if that works nicely i will push a new version 0.4 to github/npm

from sequelize.

sdepold avatar sdepold commented on May 14, 2024

and the documentation: http://sequelizejs.com/#basicMapping

from sequelize.

assertchris avatar assertchris commented on May 14, 2024

Very nice! Will try it out today.

from sequelize.

sdepold avatar sdepold commented on May 14, 2024

this seems to work :)

from sequelize.

Related Issues (20)

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.