提交 0dc931d4c6426274742dbb6cc15f7ec9cf59d3ce

作者 sandaruwan_silva
1 个父辈 020e3738

Model electrolyte fixes

1 1
2 2 // # home
3 3
  4 +var mongoose = require('mongoose')
4 5 exports = module.exports = home
5 6
6 7 function home(app, lib, modeluser) {
... ... @@ -12,29 +13,12 @@ function home(app, lib, modeluser) {
12 13
13 14 about: function(req, res, next) {
14 15 // save project data
15   - var User = modeluser;
16   -
17   - console.log(User);
18   -
19   - /*var user = new User({
20   - email: 'user@example.com',
21   - });
22   -*/
23   - var upsertData = User;//user.toObject();
24   - delete upsertData._id;
25   -
26   - User.update({email: 'user@example.com'}, upsertData, {upsert: true}, function( err, project ) {
27   -
28   - if(err){
29   - res.send(500, {message: 'Error saving project data'});
30   - return console.error('Error creating project data');
31   - }
32   -
33   - res.send(200, {message: 'success'});
34   -
  16 + var User = mongoose.model('User', modeluser);
  17 + console.log(modeluser);
  18 + User.create({name: 'john'}, function( err, project ) {
  19 + res.send(200, 'Hello, this is Igloo.')
35 20 });
36 21
37   - res.send(200, 'Hello, this is Igloo.')
38 22 }
39 23
40 24 }
... ...
1 1
2 2 // # user
3 3
4   -var mongoose = require('mongoose')
5   -var common = require('./common')
  4 +var mongoose = require('mongoose'),
  5 + common = require('./common'),
  6 + Schema = mongoose.Schema,
  7 + mongooseTypes = require('mongoose-types')
6 8
7   -var Schema = mongoose.Schema
8   -var mongooseTypes = require('mongoose-types')
9 9 mongooseTypes.loadTypes(mongoose)
10 10
11   -var Email = mongoose.SchemaTypes.Email
  11 +//var Email = mongoose.SchemaTypes.Email
12 12
13   -var User = module.exports = new Schema({
14   - email: {
  13 +var User = new Schema({
  14 + /*email: {
15 15 type: Email,
16 16 required: true,
17 17 unique: true
18   - }
  18 + }*/
  19 + name: String
19 20 })
20 21
21 22 User.plugin(common)
  23 +
  24 +module.exports = User;
  25 +
  26 +
  27 +var MUser = mongoose.model('User', User);
  28 +
  29 +var user = new MUser({
  30 + name: 'user@example.com',
  31 +});
  32 +
  33 +MUser.create({name: 'john'}, function( err, project ) {
  34 + console.log(200, 'Hello, this is Igloo.')
  35 +});
  36 +
  37 +console.log(MUser.db);
\ No newline at end of file
... ...
... ... @@ -18,7 +18,7 @@ var environments = {
18 18 host: 'localhost',
19 19 db: {
20 20 host: 'localhost',
21   - dbname: 'TODO',
  21 + dbname: 'mydb',
22 22 port: '27017',
23 23 opts: {}
24 24 },
... ...
... ... @@ -16,6 +16,7 @@ module.exports = function(_config) {
16 16 exports['@singleton'] = true;
17 17
18 18 function mongo(callback) {
  19 + console.log(config.db);
19 20 var connection = mongoose.createConnection(
20 21 config.db.host,
21 22 config.db.dbname,
... ...
... ... @@ -34,10 +34,9 @@
34 34 "electrolyte": "*",
35 35 "express-session": "~1.1.0",
36 36 "method-override": "~1.0.1",
37   - "static-favicon": "~2.0.0-alpha",
38 37 "cookie-parser": "~1.1.0",
39 38 "errorhandler": "~1.0.1",
40 39 "body-parser": "~1.2.0",
41   - "serve-favicon": "^2.0.0"
  40 + "serve-favicon": "~2.0.0"
42 41 }
43 42 }
... ...
... ... @@ -10,6 +10,7 @@ module.exports = schemas
10 10 function schemas(lib, callback) {
11 11
12 12 _.each(models, function(schema, name) {
  13 + console.log(name, '333');
13 14 lib.db.model(name, schema)
14 15 })
15 16
... ...
注册登录 后发表评论