very basic example using an existing mariadb table

32 views
Skip to first unread message

Mark Edwards

unread,
Sep 9, 2016, 12:43:48 PM9/9/16
to Sequelize
hello - sorry to ask such a basic question but i am having issues getting started with sequelize with mariaDB putting the pieces together.  

i was able to get the first example working (cut/paste) where sequelize actually creates a table, but the legacy documentation page does not show a complete example.

i would like to see an example of sequelize.js using this example legacy table created here:

CREATE TABLE Test_table ( Test_name         VARCHAR(50)    NOT NULL
                                         , Test_birthdate     DATE
                                          , Test_primary_id INT                   NOT NULL AUTO_INCREMENT
                                         , PRIMARY KEY    (Test_primary_id) 
                                           );

and then a query that replicates something the following:

SELECT  Test_birthdate "birthday!" , Test_name "Name"  FROM  Test_table ORDER BY Test_birthdate DESC;

i realize i can probably use the raw option, but it probably would be better to learn a bit more about sequelize first.

ideally, i would like to see an example where sequelize performs the full CRUD operation on this simple table.


sequelize.js looks awesome and i am eager to begin using it.

Mark Edwards

unread,
Sep 9, 2016, 2:02:50 PM9/9/16
to Sequelize
getting somewhere:

var User = sequelize.define('marksTable',
{
  Test_name          : Sequelize.STRING,
  Test_birtdate        : Sequelize.DATE,
  Test_primary_id    :  { type                :   Sequelize.INTEGER,
                                  primaryKey      :   true,
                                  autoIncrement  :   true
                                }
}, {
        tableName: 'Test_table'
});

User.findOne({ attributes: ['Test_name', 'Test_birthdate'] })
    .then(function(result) { console.log(result) } );


Thank you,

Mark Edwards

Mick Hansen

unread,
Sep 12, 2016, 2:58:31 AM9/12/16
to Mark Edwards, Sequelize
Hi Mark,

Can you be a little bit more specific about what's not working?
--
Mick Hansen
@mhansendev
mhansen.io
Reply all
Reply to author
Forward
0 new messages