{"action":"created","issue":{"url":"https://api.github.com/repos/mbdavid/LiteDB/issues/15","labels_url":"https://api.github.com/repos/mbdavid/LiteDB/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/mbdavid/LiteDB/issues/15/comments","events_url":"https://api.github.com/repos/mbdavid/LiteDB/issues/15/events","html_url":"https://github.com/mbdavid/LiteDB/issues/15","id":63052537,"number":15,"title":"Named collections suggestion","user":{"login":"JordanMarr","id":1030435,"avatar_url":"https://avatars.githubusercontent.com/u/1030435?v=3","gravatar_id":"","url":"https://api.github.com/users/JordanMarr","html_url":"https://github.com/JordanMarr","followers_url":"https://api.github.com/users/JordanMarr/followers","following_url":"https://api.github.com/users/JordanMarr/following{/other_user}","gists_url":"https://api.github.com/users/JordanMarr/gists{/gist_id}","starred_url":"https://api.github.com/users/JordanMarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JordanMarr/subscriptions","organizations_url":"https://api.github.com/users/JordanMarr/orgs","repos_url":"https://api.github.com/users/JordanMarr/repos","events_url":"https://api.github.com/users/JordanMarr/events{/privacy}","received_events_url":"https://api.github.com/users/JordanMarr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-19T17:54:57Z","updated_at":"2015-03-19T19:39:56Z","closed_at":null,"body":"Currently, the GetCollection<T> method requires a string:name parameter.  \r\nSince a .db file is limited to storing one type of entity, I'm not sure why a name is required at all.  \r\nBut if it must exist, it would be nice if it was at least changed to be an optional parameter.\r\n\r\nMaybe something like:\r\n```\r\npublic LiteCollection<T> GetCollection<T>(string name = null)\r\n{\r\n    name = name ?? typeof(T).Name;\r\n    ...\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mbdavid/LiteDB/issues/comments/83735390","html_url":"https://github.com/mbdavid/LiteDB/issues/15#issuecomment-83735390","issue_url":"https://api.github.com/repos/mbdavid/LiteDB/issues/15","id":83735390,"user":{"login":"mbdavid","id":1137197,"avatar_url":"https://avatars.githubusercontent.com/u/1137197?v=3","gravatar_id":"","url":"https://api.github.com/users/mbdavid","html_url":"https://github.com/mbdavid","followers_url":"https://api.github.com/users/mbdavid/followers","following_url":"https://api.github.com/users/mbdavid/following{/other_user}","gists_url":"https://api.github.com/users/mbdavid/gists{/gist_id}","starred_url":"https://api.github.com/users/mbdavid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbdavid/subscriptions","organizations_url":"https://api.github.com/users/mbdavid/orgs","repos_url":"https://api.github.com/users/mbdavid/repos","events_url":"https://api.github.com/users/mbdavid/events{/privacy}","received_events_url":"https://api.github.com/users/mbdavid/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T19:39:56Z","updated_at":"2015-03-19T19:39:56Z","body":"Each .db can have multiple collections and each collection needs a name.\r\n\r\nYou can use like this:\r\n\r\n```C#\r\nvar col1 = db.GetCollection<User>(\"users\");\r\nvar col2 = db.GetCollection<User>(\"inactive_users\");\r\n\r\nvar col3 = db.GetCollection<BsonDocument>(\"users\");\r\n```\r\n\r\nTwo distinct collections using same entity. Or, you can use `BsonDocument` to read/write your documents too. That's the reason to get a named to a collection.\r\n\r\nAlso, each collection store documents (that are scheme-less): each documents can have different data structures.\r\n\r\n```JS\r\ndb.col1.insert {_id:1, name: \"John\", age: 30}\r\ndb.col1.insert {_id:\"myIdString\", name: true}\r\ndb.col1.insert {age: \"ten\"}\r\ndb.col1.ensureIndex name\r\n```\r\n\r\nThis is a complete valid 3 documents, in same collection. And index works too.\r\n\r\nI recommend to use a repository pattern like this:\r\n\r\n```C#\r\npublic class MyDB : LiteDatabase\r\n{\r\n    public LiteCollection<User> Users { get; private set; }\r\n    public LiteCollection<User> ObsoleteUsers { get; private set; }\r\n\r\n    public MyDB() : base(\"stringConnection\")\r\n    {\r\n        this.Users = this.GetCollection<User>(\"user\");\r\n        this.ObsoleteUsers = this.GetCollection<User>(\"obsolete_user\");\r\n    }\r\n}\r\n\r\nusing(var db = new MyDB())\r\n{\r\n    db.Users.Find(...);\r\n}\r\n```\r\n\r\nUsing this, you will never write collection name again."}}