Tabnine Logo For Javascript
sequelize
Code IndexAdd Tabnine to your IDE (free)

How to use sequelize

Best JavaScript code snippets using sequelize(Showing top 15 results out of 1,926)

origin: atulmy/crate

connection
 .authenticate()
 .then(() => {
  console.info('INFO - Database connected.')
 })
 .catch(err => {
  console.error('ERROR - Unable to connect to the database:', err)
 })
origin: GladysAssistant/Gladys

Promise.mapSeries(reversedSeed, (seed) => callLater().then(() => seed.down(db.sequelize.getQueryInterface())))
origin: GladysAssistant/Gladys

/**
 * @description Get messages of a user
 * @param {string} userId - The id of the user.
 * @param {Object} options - Options of the request.
 * @example
 * gladys.message.get('f6cc6e0c-1b48-4b59-8ac7-9a0ad2e0ed3c', options);
 */
async function get(userId, options) {
 const optionsWithDefault = Object.assign({}, DEFAULT_OPTIONS, options);

 const queryParams = {
  attributes: optionsWithDefault.fields,
  limit: optionsWithDefault.take,
  offset: optionsWithDefault.skip,
  order: [[optionsWithDefault.order_by, optionsWithDefault.order_dir]],
  where: {
   [Op.or]: [{ sender_id: userId }, { receiver_id: userId }],
  },
 };

 const messages = await db.Message.findAll(queryParams);

 const plainMessages = messages.map((message) => message.get({ plain: true }));

 return plainMessages;
}
origin: GladysAssistant/Gladys

/**
 * @description Purge device states
 * @example
 * device.purgeStates();
 */
async function purgeStates() {
 logger.debug('Purging device feature states...');
 const deviceStateHistoryInDays = await this.variable.getValue(SYSTEM_VARIABLE_NAMES.DEVICE_STATE_HISTORY_IN_DAYS);
 const deviceStateHistoryInDaysInt = parseInt(deviceStateHistoryInDays, 10);
 if (Number.isNaN(deviceStateHistoryInDaysInt)) {
  logger.debug('Not purging device feature states.');
  return;
 }
 const queryInterface = db.sequelize.getQueryInterface();
 const now = new Date().getTime();
 // all date before this timestamp will be removed
 const timstampLimit = now - deviceStateHistoryInDaysInt * 24 * 60 * 60 * 1000;
 await queryInterface.bulkDelete('t_device_feature_state', {
  created_at: {
   [Op.lte]: new Date(timstampLimit),
  },
 });
}
origin: GladysAssistant/Gladys

db.sequelize.transaction(async (transaction) => {
   const service = await db.Service.findOne({
    where: {
origin: GladysAssistant/Gladys

/**
 * @public
 * @description Get house
 * @param {Object} [options] - Options of the query.
 * @param {Array} options.expand - Array of fields to expand.
 * @returns {Promise} Resolve with array of houses.
 * @example
 * const houses = await gladys.house.get();
 */
async function get(options) {
 const optionsWithDefault = Object.assign({}, DEFAULT_OPTIONS, options);
 const queryParams = {
  include: [],
  order: [[optionsWithDefault.order_by, optionsWithDefault.order_dir]],
 };
 if (optionsWithDefault.expand.includes('rooms')) {
  queryParams.include.push({
   model: db.Room,
   as: 'rooms',
  });
 }
 if (optionsWithDefault.search) {
  queryParams.where = Sequelize.where(Sequelize.fn('lower', Sequelize.col('t_house.name')), {
   [Op.like]: `%${optionsWithDefault.search}%`,
  });
 }
 const houses = await db.House.findAll(queryParams);
 const housesPlain = houses.map((house) => house.get({ plain: true }));
 return housesPlain;
}
origin: GladysAssistant/Gladys

 category: DEVICE_FEATURE_CATEGORIES.CAMERA,
 last_value_string: {
  [Op.not]: null,
 },
 last_value_changed: {
  [Op.gt]: oneHourAgo,
 },
},
origin: GladysAssistant/Gladys

queryParams.where = Sequelize.where(Sequelize.fn('lower', Sequelize.col('name')), {
 [Op.like]: `%${optionsWithDefault.search}%`,
});
origin: GladysAssistant/Gladys

return db.sequelize.transaction(async (t) => {
 const locationWithUserId = Object.assign({}, location, {
  user_id: user.id,
origin: GladysAssistant/Gladys

 [Op.gte]: new Date(fromDate),
 [Op.lte]: new Date(toDate),
};
 [Op.eq]: options.selector,
};
 [Op.eq]: options.url,
};
 [Op.eq]: options.externalId,
};
 [Op.eq]: options.calendarId,
};
origin: GladysAssistant/Gladys

 last_value_changed: now,
});
await db.sequelize.transaction(async (t) => {
origin: GladysAssistant/Gladys

 user_id: user.id,
 created_at: {
  [Op.gte]: fromDate,
  [Op.lte]: toDate,
 },
},
origin: GladysAssistant/Gladys

Promise.mapSeries(seeds, (seed) => callLater().then(() => seed.up(db.sequelize.getQueryInterface())))
origin: atulmy/crate

connection
 .authenticate()
 .then(() => {
  console.info('INFO - Database connected.')
 })
 .catch(err => {
  console.error('ERROR - Unable to connect to the database:', err)
 })
origin: GladysAssistant/Gladys

db.sequelize.transaction(async (transaction) => {
   const service = await db.Service.findOne({
    where: {
sequelize(npm)

JSDoc

Multi dialect ORM for Node.JS

Most used sequelize functions

  • Sequelize.sync
    Sync all defined models to the DB.
  • Model.name
    The singular name of the model
  • Model.create
    Builds a new model instance and calls save on it.
  • Model.findAll
    Search for multiple instances.
  • Model.findOne
    Search for a single instance. This applies LIMIT 1, so the listener will always be called with a sin
  • Sequelize.authenticate,
  • between,
  • Sequelize.query,
  • STRING,
  • Sequelize.define,
  • SequelizeStatic.STRING,
  • like,
  • Model.destroy,
  • or,
  • SequelizeStatic.INTEGER,
  • iLike,
  • INTEGER,
  • Model.update,
  • gt

Popular in JavaScript

  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • aws-sdk
    AWS SDK for JavaScript
  • minimatch
    a glob matcher in javascript
  • chalk
    Terminal string styling done right
  • js-yaml
    YAML 1.2 parser and serializer
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • crypto
  • node-fetch
    A light-weight module that brings window.fetch to node.js
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now