Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Save function was not able to save my data #141

Closed
rack021 opened this issue Sep 30, 2016 · 4 comments
Closed

Save function was not able to save my data #141

rack021 opened this issue Sep 30, 2016 · 4 comments

Comments

@rack021
Copy link

rack021 commented Sep 30, 2016

const DB = require('mongorito');
const Model = DB.Model;
const run = require('./util/run');

class User extends Model {
constructor() {
super();
this.name = String;
}
}

DB.connect("localhost:27017/settrip_db").then(function (db) {
run(function* () {
var user1 = new User({
'name': 'Rac'
});
yield user1.save();
console.log(user1.get());
yield DB.disconnect();
});

});

// result

{ created_at: 2016-09-30T09:25:46.841Z,
updated_at: 2016-09-30T09:25:46.841Z,
_id: 57ee2f9a1101e708c81b8cb7 }

I don't know why, but it was not able to save my data in db, can explain what i am doing wrong?

@vadimdemedes
Copy link
Owner

class User extends Model {
constructor() {
super();
this.name = String;
}
}

Mongorito does not have schemas, try removing this.name = String.

@rack021
Copy link
Author

rack021 commented Sep 30, 2016

Oh, Gosh, how did I miss that, thank you very much, and thank you for such great ORM

@rack021 rack021 closed this as completed Sep 30, 2016
@vadimdemedes
Copy link
Owner

vadimdemedes commented Sep 30, 2016

Glad you like it, v3 is coming soon ;)

@rack021
Copy link
Author

rack021 commented Sep 30, 2016

I am waiting for it, I wish it can be released today itself so, i can incorporate in my new project from initial phase itself and we don't need to update it later. :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants