1.1.2 • Published 7 years ago

moonlight_function_common v1.1.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
7 years ago

#This is a function from Moonlight ##Prerequisite:

Rewquire: moonlight_function_errplace use: npm install moonlight_function_errplace
Require: ioredis use: npm install ioredis

#Quick Start ##install npm install moonlight_function_common ##Basic Usage

##Https ###get

get(host, url,function(callback){
    ......
});

###post post data to htpps://host+url (data must be string format)

var host = "qyapi.weixin.qq.com";
var url = "/cgi-bin/user/create?access_token=" + access_token;
var content=JSON.stringify(data);
post(host, url,content,function(resutl){
    console.log(page_name+":the post result: "+result);

});

##Mongodb

###Method insert

var com=require('moonlight_function_common');
var mongodb = com.mongodb;
mongodb.insert (document)  {
      ......
 }
 mongodb.insert (document , options)  {
      ......
 }
 mongodb.insert (document , function (err,result)  {
      ......
 }
 mongodb.insert (document, options , function (err,result)  {
     ......
}

##Redis

var com=require('moonlight_function_common');
var redis=com.redis;

####set_key: redis.setex_key(key,seconds,value); //Such as redis.setex_key(key,7200,access_token); // 7200seconds

//put value in redis by key_name key, expire time seconds.

####get_key: get a value from redis by the key_name key, the value callback in the result. if result is NULL, is means that there is not a vaule in redis by the key_name key. Such as:

redis.getkey(key,function(result){
    access_token_callback(result);
});
1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago