Size: a a a

Sequelize - community (eng/ru)

2020 February 02

ii

iCheater iCheater in Sequelize - community (eng/ru)
🤦‍♂️
источник

ii

iCheater iCheater in Sequelize - community (eng/ru)
JEST is too smart...
источник

LA

Luis Azcuaga in Sequelize - community (eng/ru)
iCheater iCheater
JEST is too smart...
👀 what was it? 👀👀
источник

ii

iCheater iCheater in Sequelize - community (eng/ru)
Luis Azcuaga
👀 what was it? 👀👀
Well, i thought that is
JEST starts proccess with env "test". Config.json had username: root .
So, it was me and JEST :)
if (config.use_env_variable) {
 sequelize = new Sequelize(process.env[config.use_env_variable], config)
} else {
 sequelize = new Sequelize(config.database, config.username, config.password, config)
}
источник

LA

Luis Azcuaga in Sequelize - community (eng/ru)
Oooooh so it was using another config for testing.
источник
2020 February 11

BD

Binyam Dele in Sequelize - community (eng/ru)
источник

YZ

Yaroslav Zhymkov in Sequelize - community (eng/ru)
you define between-table manualy, sequelzie don't know about it while insert data
источник

YZ

Yaroslav Zhymkov in Sequelize - community (eng/ru)
try to add id field in RestaurantsWorkingDay model
источник

YZ

Yaroslav Zhymkov in Sequelize - community (eng/ru)
or look guide how to work with many-to-many relation
источник

BD

Binyam Dele in Sequelize - community (eng/ru)
Yaroslav Zhymkov
try to add id field in RestaurantsWorkingDay model
\node_modules\sequelize\lib\model.js:230
       throw new Error(A column called 'id' was added to the attributes of '${this.tableName}' but not marked with 'primaryKey: true');
источник

BD

Binyam Dele in Sequelize - community (eng/ru)
is there any config that could i  add into ./models/index.js
источник

YZ

Yaroslav Zhymkov in Sequelize - community (eng/ru)
try to add primaryKey: true
источник

BD

Binyam Dele in Sequelize - community (eng/ru)
once I see in docs that sequelize will remove ID of joint table when two ID's comes into one table
источник

BD

Binyam Dele in Sequelize - community (eng/ru)
Yaroslav Zhymkov
try to add primaryKey: true
I did it but nothing changed
источник

YZ

Yaroslav Zhymkov in Sequelize - community (eng/ru)
источник

BD

Binyam Dele in Sequelize - community (eng/ru)
thanks
источник
2020 February 12

ii

iCheater iCheater in Sequelize - community (eng/ru)
I have models:
product  [id, ..., features]
category  [id, ..., featuresFilter]
features is json, that stores data about product (color, material etc)
featuresFilter is json, that aggregates all features from products of its category

i am going to use featuresFilter as list of dimanic filters on the category page.

home -> store -> category -> notepads
here, on category notepads page ill send to template featuresFilter and show only available filters.
When i add or remove product ill recalculate featuresFilter.

well, my thoughts:
1.i know that i can add hook "afterCreate" to product model and call something like Category.addFeaturesToFeaturesFilter(features, categoryID) {
// Category.findbyPK(categoryID).then(...) // then do some stuff
should i do it here?
}
2.  i can do the same during creating or deleting product in controllers
I know how to make the second option, but i dont know about the first.
Any advices?
источник
2020 February 14

🌠

🌠 in Sequelize - community (eng/ru)
Привет, есть модель в которой будет колонка coordibates типа POINT, не совсем понимаю как описать тип для этой колонки, в базе выглядит как POINT(24, 55)

приходит клиенту как

{
           "type": "Point",
           "coordinates": [
               42.3446304,
               -71.0310138
           ]
       }

В sequlize нашел тип для такоого типа данных

@Column({ type: DataType.GEOMETRY('POINT'), allowNull: true })


но в модели как описать, как приходит? типа такого?

 coordinates: {
   type: string,
   coordinates: [number, number],
 };
источник

GS

Grigorii K. Shartsev in Sequelize - community (eng/ru)
🌠
Привет, есть модель в которой будет колонка coordibates типа POINT, не совсем понимаю как описать тип для этой колонки, в базе выглядит как POINT(24, 55)

приходит клиенту как

{
           "type": "Point",
           "coordinates": [
               42.3446304,
               -71.0310138
           ]
       }

В sequlize нашел тип для такоого типа данных

@Column({ type: DataType.GEOMETRY('POINT'), allowNull: true })


но в модели как описать, как приходит? типа такого?

 coordinates: {
   type: string,
   coordinates: [number, number],
 };
источник

🌠

🌠 in Sequelize - community (eng/ru)
да, это я уже нашел, тут скорее оффтоп у меня немного тк скорее мой вопрос про то как описать эту колонку в несте + тайпскрипт

если не ошибаюсь можно просто указать так:

@Column({ type: DataType.GEOMETRY('POINT'))
 coordinates: {
   type: string,
   coordinates: [number, number],
 };


ну исходя из того что из базы оно отдается в таком виде:

{
           "type": "Point",
           "coordinates": [
               42.3446304,
               -71.0310138
           ]
       }
источник