{"id":17864638,"url":"https://github.com/danielfireman/tsmgo","last_synced_at":"2026-05-02T04:41:04.017Z","repository":{"id":78477157,"uuid":"145599986","full_name":"danielfireman/tsmgo","owner":"danielfireman","description":"#golang library which makes intuitive to work with time-series data in Mongo DB.","archived":false,"fork":false,"pushed_at":"2018-08-27T16:36:56.000Z","size":470,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T13:03:46.016Z","etag":null,"topics":["golang-library","golang-package","mongodb","time-series"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielfireman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-21T17:54:55.000Z","updated_at":"2021-08-26T23:33:23.000Z","dependencies_parsed_at":"2023-04-12T06:46:41.933Z","dependency_job_id":null,"html_url":"https://github.com/danielfireman/tsmgo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielfireman/tsmgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfireman%2Ftsmgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfireman%2Ftsmgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfireman%2Ftsmgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfireman%2Ftsmgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielfireman","download_url":"https://codeload.github.com/danielfireman/tsmgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfireman%2Ftsmgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32523428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang-library","golang-package","mongodb","time-series"],"created_at":"2024-10-28T09:13:49.681Z","updated_at":"2026-05-02T04:41:04.001Z","avatar_url":"https://github.com/danielfireman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/danielfireman/tsmgo.svg?branch=master)](https://travis-ci.org/danielfireman/tsmgo) [![Coverage Status](https://codecov.io/gh/danielfireman/tsmgo/branch/master/graph/badge.svg)](https://codecov.io/gh/danielfireman/tsmgo/branch/master/graph/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/danielfireman/tsmgo)](https://goreportcard.com/report/github.com/danielfireman/tsmgo) [![GoDoc](https://godoc.org/github.com/danielfireman/tsmgo?status.svg)](https://godoc.org/github.com/danielfireman/tsmgo)\n\n# tsmgo\n\n#golang library which makes intuitive to work with time-series data in Mongo DB.\n\nThe schema design is inspired by [this article](https://www.mongodb.com/blog/post/schema-design-for-time-series-data-in-mongodb).\n\n# Using tsmgo\n\n```go\nimport \"github.com/danielfireman/tsmgo\"\n```\n\n**New tsmgo.Session**\n\n```go\ntsSession := tsmgo.NewSession(mgoSession)\nc, _ := tsSession.C(dbName, colName)\n```\n\nor\n\n```go\ntsSession, err := tsmgo.Dial(mongoURL)\nc, _ := tsSession.C(dbName, colName)\n```\n\nWhere mgoSession is a [github.com/globalsign/mgo#Session](https://godoc.org/github.com/globalsign/mgo#Session).\n\n**Adding timeseries records**\n\n```go\nc.Upsert(myField, TSRecord{time.Now(), 1})\n```\n\nor\n\n```go\nt1 := time.Now()\nt2 := t1.Add(10 * time.Second)\nc.Upsert(myField, TSRecord{t1, 1}, TSRecord{t2, 2})\n```\n\n**Retrieving last item inserted**\n```go\nlast, _ := tsmgoC.Last(myField)\n```\n\n**Retrieving all itens inserted in the last 24 hours**\n```go\nnow := time.Now()\nitems, _ := tsmgoC.Interval(myField, now.Add(-24*time.Hour), now)\n```\n\n# Contributing\n\n1. Install [dep](https://github.com/golang/dep/blob/master/docs/installation.md)\n1. `dep ensure`\n1. `go test -v`\n\nEither if you're fixing a bug or adding a new feature, please add a test to cover it.\n\nIf all tests passes, please you're ready to send the PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfireman%2Ftsmgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielfireman%2Ftsmgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfireman%2Ftsmgo/lists"}