小编taj*_*din的帖子

如何使用sailsjs v0.10连接mongodb?

现在使用sailsjs v0.10.配置connections.js和models.js并将其更改为connection:'localMongodbServer',安装npm install sails-mongo.

所有这一切都显示错误

 var des = Object.keys(dbs[collectionName].schema).length === 0 ?
                                          ^
TypeError: Cannot read property 'schema' of undefined

at Object.module.exports.adapter.describe (app1_test/node_modules/sails-mongo/lib/adapter.js:70:48)
Run Code Online (Sandbox Code Playgroud)

如果将collections.js更改为adapter.js显示错误

  [err] In model (model1), invalid connection :: someMongodbServer
  [err] Must contain an `adapter` key referencing the adapter to use.
Run Code Online (Sandbox Code Playgroud)

mongodb node.js sails.js

17
推荐指数
2
解决办法
2万
查看次数

如何在Sails中使用mocha测试控制器?

我的Controller登录页面有以下内容:

// Authentication Controller
// the basics of Passport.js to work.
var AuthController = {

    // localhost:1337/login  Render the login page
    // <form role="form" action="/auth/local" method="post">
    //     <input type="text" name="identifier" placeholder="Username or Email">
    //     <input type="password" name="password" placeholder="Password">
    //     <button type="submit">Sign in</button>
    // </form>

    login: function(req, res) {
        var strategies = sails.config.passport,
            providers = {};

        // Get a list of available providers for use in templates.
        Object.keys(strategies).forEach(function(key) {
            if (key === 'local') return;
            providers[key] = {
                name: strategies[key].name, …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing mocha.js node.js sails.js

5
推荐指数
1
解决办法
2391
查看次数

标签 统计

node.js ×2

sails.js ×2

javascript ×1

mocha.js ×1

mongodb ×1

unit-testing ×1