代码拉取完成,页面将自动刷新
'use strict';
const app = require("tcb-admin-node");
function times33(str){
for(var i = 0, len = str.length,hash = 5381; i < len; ++i){
hash += (hash << 5) + str.charCodeAt(i);
};
return hash & 0x7fffffff;
}
exports.main = async (event, context, callback) => {
app.init({env: process.env.ENV})
const db = app.database();
const _ = db.command;
let DB = process.env.DB
let callbackfunciton = "callback"
var accessHash = times33("wu"+process.env.accessKey).toString(36)+times33("han"+process.env.accessKey).toString(36);
var accessHash2 = times33("wu"+process.env.accessKey2).toString(36)+times33("han"+process.env.accessKey2).toString(36);
console.log(accessHash2)
var collection;
if(event.path && (event.path.indexOf(accessHash)>-1 || event.path.indexOf(accessHash2)>-1)){
DB = process.env.CASE_DB
callbackfunciton = "detailCallback"
collection=db.collection(DB);
}else{
DB = process.env.CASE_DB
callbackfunciton = "caseCallback"
collection = db.collection(DB).field({ 'lng': true,'lat': true,"types":true })
}
let limit = 999,skip=0;
let all = [],t=new Array(limit);
for(;(t.length == limit);skip+=limit){
t=(await collection.skip(skip).limit(limit).get()).data;
all = all.concat(t);
}
for(var i=0;i<all.length;i++){
delete all[i]._id
}
return {
'isBase64Encoded': false,
'statusCode' : 200,
'headers' : {'Content-Type':'application/x-javascript; charset=utf-8'},
'body' : callbackfunciton+"("+JSON.stringify(all)+")"
};
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。