本文整理汇总了TypeScript中mongojs.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach((next) => {
var db = mongojs(process.env.MONGO_URI, ["logger"]);
db["logger"].remove({}, next);
});
开发者ID:data-avail,项目名称:da-helpers,代码行数:4,代码来源:logger.spec.ts
示例2: createTodoApi
export function createTodoApi() {
let mongojs = require('mongojs');
let router = Router();
let db = mongojs('mongodb://admin:[email protected]:37827/ng2todoapp', ['todos']);
/* GET All Todos */
router.get('/todos', function(req, res, next) {
db.todos.find(function(err, todos) {
if (err) {
res.send(err);
} else {
res.json(todos);
}
});
});
/* GET One Todo with the provided ID */
router.get('/todo/:id', function(req, res, next) {
db.todos.findOne({
_id: mongojs.ObjectId(req.params.id)
}, function(err, todos) {
if (err) {
res.send(err);
} else {
res.json(todos);
}
});
});
/* POST/SAVE a Todo */
router.post('/todo', function(req, res, next) {
var todo = req.body;
if (!todo.text || !(todo.isCompleted + '')) {
res.status(400);
res.json({
"error": "Invalid Data",
'todo': todo
});
} else {
db.todos.save(todo, function(err, result) {
if (err) {
res.send(err);
} else {
res.json(result);
}
})
}
});
/* PUT/UPDATE a Todo */
router.put('/todo/:id', function(req, res, next) {
var todo = req.body;
var updObj = { 'isCompleted': false, 'text': ''};
if (todo.isCompleted) {
updObj.isCompleted = todo.isCompleted;
}
if (todo.text) {
updObj.text = todo.text;
}
if (!updObj) {
res.status(400);
res.json({
"error": "Invalid Data"
});
} else {
db.todos.update({
_id: mongojs.ObjectId(req.params.id)
}, updObj, {}, function(err, result) {
if (err) {
res.send(err);
} else {
res.json(result);
}
});
}
});
/* DELETE a Todo */
router.delete('/todo/:id', function(req, res) {
db.todos.remove({
_id: mongojs.ObjectId(req.params.id)
}, '', function(err, result) {
if (err) {
res.send(err);
} else {
res.json(result);
}
});
});
return router;
}
开发者ID:Codenator81,项目名称:ng2do-mean-app,代码行数:87,代码来源:api.ts
示例3: handle
/// <reference path="../typings/tsd.d.ts" />
var Promise = require("bluebird");
var mongojs = require("mongojs");
var mongoUrl = process.env.MONGO_PORT_27017_TCP_ADDR ?
"mongodb://#{process.env.MONGO_PORT_27017_TCP_ADDR}:#{process.env.MONGO_PORT_27017_TCP_PORT}" :
process.env.MONGO_HANDLER_URI;
var mongoCollection = process.env.MONGO_HANDLER_COLLECTION;
var db = mongojs(mongoUrl, [mongoCollection]);
var coll : any = Promise.promisifyAll(db[mongoCollection]);
var findAsync : <T>(query: any) => Promise<T[]> = Promise.promisify(coll.find, coll)
interface IPosition {
_id: string
ticker: string
}
export function handle (portfolio: tn.ITraderNetPortfolio) {
findAsync<IPosition>({}).then((res) =>
console.log("handler.ts:24>>>", res)
);
}
exports.handle = handle;
开发者ID:data-avail,项目名称:docker-bee-tmpl,代码行数:26,代码来源:handler.ts
示例4: constructor
constructor(opts: ILoggerOpts, mongoOpts : ILoggerMongoOpts) {
this.tags = [opts.pack.name, opts.pack.ver].concat(opts.tags).filter((f) => !!f);
this.db = mongojs(mongoOpts.connection, [mongoOpts.collection]);
this.insertAsync = promise.promisify(this.db[mongoOpts.collection].insert, this.db[mongoOpts.collection]);
}
开发者ID:data-avail,项目名称:da-helpers,代码行数:6,代码来源:logger-mongo.ts
示例5: get
/// <reference path="../../node.d.ts" />
/// <reference path="../../express.d.ts" />
var mongojs = require("mongojs");
/**
*
* config: { collection: 'components', db: 'exampledb' }
*
*/
var db = mongojs('appchix'),
Component = db.collection('components');
export module rest {
export function get(req, res) {
};
export function post(req, res) {
/*
var v = request.body;
var schema_uri = null;
var datasource_uri = null;
var filter = { _id: null };
var obj = {
type: v.path,
schema: schema_uri, // Schema to validate what is inside config.
开发者ID:psichi,项目名称:chix-modules,代码行数:31,代码来源:module.ts
注:本文中的mongojs.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论