zoukankan      html  css  js  c++  java
  • nodejs开发微信1——微信access-token和tickets的数据模型

     1 /* jshint -W079 */
     2 /* jshint -W020 */
     3 
     4 "use strict";
     5 //var _ = require("lodash");
     6 
     7 module.exports = function(utils, db) {
     8 
     9     // Model WeChatAccessTokenSchema
    10     var WeChatAccessTokenSchema = new db.Schema({
    11         appid:  {type: String, trim:true, required: true },
    12         access_token: {type: String, trim:true},
    13         expires_in: Number,
    14         at: {type: Number, default: parseInt(new Date().getTime() / 1000)},
    15         create_at: {type: Date, default: Date.now}
    16     }, db.schema_options);
    17 
    18     WeChatAccessTokenSchema.index({ appid: 1 });
    19     WeChatAccessTokenSchema.index({ access_token: 1 });
    20 
    21     global.WeChatAccessToken = db.mongoose.model('WeChatAccessToken', WeChatAccessTokenSchema);
    22 
    23     // Model WeChatTicketSchema
    24     var WeChatTicketSchema = new db.Schema({
    25         appid: {type: String, trim:true, required: true},
    26         ticket: {type: String, trim:true},
    27         noncestr: {type: String, trim:true},
    28         expires_in: Number,
    29         at: {type: Number, default: parseInt(new Date().getTime() / 1000)},
    30         create_at: {type: Date, default: Date.now}
    31     }, db.schema_options);
    32 
    33     WeChatTicketSchema.index({ appid: 1 });
    34     WeChatTicketSchema.index({ ticket: 1 });
    35 
    36     global.WeChatTicket = db.mongoose.model('WeChatTicket', WeChatTicketSchema);
    37 };

    数据库中只保存这两条数据,每次请求都是更新,不会增加;

    这是mvc模式中的m,数据模型,

    坚持下去就能成功
  • 相关阅读:
    【python-plt】二元正态密度函数图像
    【python-plt】一元正态分布图像
    【7】极大似然估计与贝叶斯估计
    实变函数【1】集合
    图形学-心得
    分布式网络架构
    shader的内置变量
    图形学-绘制
    python加载图片
    linux下批量删除utf8 bom
  • 原文地址:https://www.cnblogs.com/suoking/p/5206569.html
Copyright © 2011-2022 走看看