How to use the sequelize.NOW function in sequelize

To help you get started, we’ve selected a few sequelize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keenwon / eazydict / src / dao / model / HistoryModel.js View on Github external
},

  // 缓存的插件列表
  plugins: {
    type: Sequelize.STRING
  },

  // 缓存查询结果
  output: {
    type: Sequelize.JSON
  },

  // 生成缓存的时间
  cacheAt: {
    type: Sequelize.DATE,
    defaultValue: Sequelize.NOW
  }
}

const options = {
  indexes: [
    {
      fields: ['words']
    },
    {
      fields: [
        {
          attribute: 'count',
          order: 'DESC'
        }
      ]
    },
github zalando / zappr / server / model / Repository.js View on Github external
defaultValue: false
  },
  json: {
    type: Sequelize.JSONB,
    allowNull: false,
    get: deserializeJson('json')
  },
  createdAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW()
  },
  updatedAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW()
  }
}, {
  scopes: {
    userId: userId => ({
      include: [{
        model: User,
        where: {id: userId},
        through: {
          attributes: [] // prevents association table from being included in the result
        }
      }]
    })
  },
  instanceMethods: {
    setJson: function (path, value) {
      if (db.getDialect() === 'postgres') {
github maoxiaoquan / kite / db / mysqldb / models_type / db_article_blog.js View on Github external
comment: '驳回,或者文章审核不通过的原因',
      field: 'rejection_reason'
    },
    like_count: {
      // 喜欢数
      type: Seq.BIGINT(20),
      comment: '喜欢数',
      field: 'like_count',
      defaultValue: 0
    },
    update_date: {
      // 更新时间
      type: Seq.DATE,
      comment: '更新时间',
      field: 'update_date',
      defaultValue: Seq.NOW /* 时间 */
    },
    ...time.create_date
  }
}
github miconblog / devcafe / server / app / models / read_post.model.js View on Github external
type: Sequelize.INTEGER(11).UNSIGNED,
    primaryKey: true,
    allowNull: false,
    field: 'member_id'
  },

  postId: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    primaryKey: true,
    allowNull: false,
    field: 'post_id'
  },

  lastUpdatedAt: {
    type: Sequelize.DATE,
    defaultValue: Sequelize.NOW,
    field: 'last_updated_at'
  }

}, {

  getterMethods: {

  },
  setterMethods: {

  },

  classMethods: {

  },
github miconblog / devcafe / server / app / models / board.model.js View on Github external
*  R-생성요청 - 게시판 생성을 요청하는 곳이다.
   */
  type: {
    type: Sequelize.ENUM('N', 'C', 'T','R'),
    allowNull: false,
  },

  companyId: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    field: 'company_id'
  },

  createdAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW,
    field: 'created_at'
  },

  updatedAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW,
    field: 'updated_at'
  },

  openingAt: {
    type: Sequelize.DATE,
    field: 'opening_at'
  },

  closingAt: {
github SteveMcGrath / DoFler / lib / models.js View on Github external
var Sequelize = require('sequelize');
var base64Img = require('base64-img');
var config = require('config');
var sequelize = new Sequelize(config.Database.uri, {logging: config.Database.logging});


var Image = sequelize.define('image', {
	id: {type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true},
	hash: Sequelize.STRING(32),
	count: {type: Sequelize.INTEGER, defaultValue: 0},
	url: Sequelize.STRING,
	filename: {type: Sequelize.STRING(42), unique: true},
	date: {type: Sequelize.DATE, defaultValue: Sequelize.NOW},
	nsfw: {type: Sequelize.INTEGER} 
},{
	instanceMethods: {
		b64: function() {
			return base64Img.base64Sync(config.AppServer.images + '/' + this.filename);
		}
	}
})

var Account = sequelize.define('account', {
	id: {type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true},
	username: Sequelize.STRING,
	password: Sequelize.STRING,
	information: Sequelize.STRING,
	protocol: Sequelize.STRING,
	parser: Sequelize.STRING,
github miconblog / devcafe / server / app / models / board.model.js View on Github external
companyId: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    field: 'company_id'
  },

  createdAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW,
    field: 'created_at'
  },

  updatedAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW,
    field: 'updated_at'
  },

  openingAt: {
    type: Sequelize.DATE,
    field: 'opening_at'
  },

  closingAt: {
    type: Sequelize.DATE,
    field: 'closing_at'
  }

}, {

  getterMethods: {
github interledger-deprecated / ilp-kit / api / src / migrations / 20170124-settlement.js View on Github external
references: {
          model: 'Peers',
          key: 'id'
        }
      },
      settlement_method_id: {
        type: Sequelize.UUID,
        references: {
          model: 'SettlementMethods',
          key: 'id'
        }
      },
      created_at: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      },
      updated_at: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      }
    })
  },
  down: sequelize => {
github emanuelcasco / typescript-orm-benchmark / src / sequelize / models / Order.ts View on Github external
export const OrderFactory = (
  sequelize: Sequelize.Sequelize,
  DataTypes: Sequelize.DataTypes
): OrderModel => {
  const Order: OrderModel = sequelize.define(
    'orders',
    {
      id: {
        type: DataTypes.STRING,
        autoIncrement: true,
        primaryKey: true
      },
      user: { type: DataTypes.STRING },
      date: {
        type: DataTypes.DATE,
        defaultValue: Sequelize.NOW
      }
    }
  );

  Order.associate = (models): void => {
    Order.belongsToMany(models.Item,  {
      through: 'orders_items',
      as: 'items',
      foreignKey: 'order_id'
    })
  };

  return Order;
};
github zalando / zappr / server / model / Check.js View on Github external
type: Sequelize.INTEGER,
    allowNull: true
  },
  last_execution_successful: {
    type: Sequelize.BOOLEAN,
    allowNull: true
  },
  createdAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW()
  },
  updatedAt: {
    type: Sequelize.DATE,
    allowNull: false,
    defaultValue: Sequelize.NOW()
  }
}, {
  schema: db.schema,
  timestamps: true,
  createdAt: 'createdAt',
  updatedAt: 'updatedAt',
  instanceMethods: {
    /**
     * Never return the token in JSON.
     *
     * @override
     * @returns {object}
     */
    toJSON: function () {
      const json = this.get({plain: true})
      delete json.token

sequelize

Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.

MIT
Latest version published 28 days ago

Package Health Score

95 / 100
Full package analysis