{"action":"created","issue":{"url":"https://api.github.com/repos/aexmachina/factory-girl/issues/48","repository_url":"https://api.github.com/repos/aexmachina/factory-girl","labels_url":"https://api.github.com/repos/aexmachina/factory-girl/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/aexmachina/factory-girl/issues/48/comments","events_url":"https://api.github.com/repos/aexmachina/factory-girl/issues/48/events","html_url":"https://github.com/aexmachina/factory-girl/issues/48","id":156887750,"number":48,"title":"Should Factory.build() create associated objects? ","user":{"login":"SeanDunford","id":1704718,"avatar_url":"https://avatars.githubusercontent.com/u/1704718?v=3","gravatar_id":"","url":"https://api.github.com/users/SeanDunford","html_url":"https://github.com/SeanDunford","followers_url":"https://api.github.com/users/SeanDunford/followers","following_url":"https://api.github.com/users/SeanDunford/following{/other_user}","gists_url":"https://api.github.com/users/SeanDunford/gists{/gist_id}","starred_url":"https://api.github.com/users/SeanDunford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeanDunford/subscriptions","organizations_url":"https://api.github.com/users/SeanDunford/orgs","repos_url":"https://api.github.com/users/SeanDunford/repos","events_url":"https://api.github.com/users/SeanDunford/events{/privacy}","received_events_url":"https://api.github.com/users/SeanDunford/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-26T01:57:59Z","updated_at":"2016-05-27T02:46:26Z","closed_at":"2016-05-26T07:54:28Z","body":"Is it expected behavior for factory-girl to create (save to db) associated objects when you call .build on a factory? If I'm calling .build I'm not expecting any docs to be saved to the database.  \r\n\r\nReproduce code\r\n```javascript\r\nvar factory = require('factory-girl');\r\nvar db = require('myDbConnection');\r\nvar mongoose = require('mongoose');\r\nvar Schema = mongoose.Schema;\r\nvar ObjectId = Schema.Types.ObjectId;\r\n\r\nvar userSchema = new Schema({\r\n    post: {type: ObjectId, ref: 'user'}\r\n});\r\n\r\nvar postSchema = new Schema({\r\n    text: {type: String}\r\n});\r\n\r\nvar UserModel = db('test').model('user', userSchema);\r\nvar PostModel = db('test').model('post', postSchema)\r\n\r\nfactory.define('user', UserModel, {\r\n    post: factory.assoc('post', '_id')\r\n});\r\n\r\nfactory.define('post', PostModel, {\r\n    text: 'Hello.'\r\n});\r\n\r\nfactory.build('user', {}, function(err, user){\r\n    if(err) throw err;\r\n    console.log('user: ', user);  \r\n});\r\n```\r\n\r\nAfter the callback is executed user is a valid doc and has a valid _id but isn't saved to the db. Yet, Post was saved to the db. I would expect both to be non-saved models. "},"comment":{"url":"https://api.github.com/repos/aexmachina/factory-girl/issues/comments/222047628","html_url":"https://github.com/aexmachina/factory-girl/issues/48#issuecomment-222047628","issue_url":"https://api.github.com/repos/aexmachina/factory-girl/issues/48","id":222047628,"user":{"login":"SeanDunford","id":1704718,"avatar_url":"https://avatars.githubusercontent.com/u/1704718?v=3","gravatar_id":"","url":"https://api.github.com/users/SeanDunford","html_url":"https://github.com/SeanDunford","followers_url":"https://api.github.com/users/SeanDunford/followers","following_url":"https://api.github.com/users/SeanDunford/following{/other_user}","gists_url":"https://api.github.com/users/SeanDunford/gists{/gist_id}","starred_url":"https://api.github.com/users/SeanDunford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeanDunford/subscriptions","organizations_url":"https://api.github.com/users/SeanDunford/orgs","repos_url":"https://api.github.com/users/SeanDunford/repos","events_url":"https://api.github.com/users/SeanDunford/events{/privacy}","received_events_url":"https://api.github.com/users/SeanDunford/received_events","type":"User","site_admin":false},"created_at":"2016-05-27T02:46:26Z","updated_at":"2016-05-27T02:46:26Z","body":"Beautiful, thank you. Thanks for turning that around so fast. "}}
{"actor":{"display_login":"SeanDunford"}}