Skip to content

Mongo ODM (Object Document Mapper) with repositories for crystal lang

License

Notifications You must be signed in to change notification settings

glassy-framework/glassy-mongo-odm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glassy-mongo-odm

CircleCI

Mongo ODM (Object Document Mapper) with repositories for crystal lang

TODO

  • Serialize & Deserialize
  • Connection Pool
  • Thread Safety

Currently, in the container, we are creating several instances

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      glassy-mongodb-odm:
        github: glassy-framework/glassy-mongo-odm
  2. Run shards install

Usage

require "glassy-mongo-odm"

include Glassy::MongoODM::Annotations

@[ODM::Document]
class User
  @[ODM::Id]
  property id : BSON::ObjectId?

  @[ODM::Field(name: "Name")]
  property name : String

  @[ODM::Field]
  property birth_date : Time

  @[ODM::Field]
  property mother : Mother?

  @[ODM::Document]
  class Mother
    @[ODM::Field]
    property name : String?
  end

  def initialize(@name, @birth_date)
  end
end

class UserRepository < Glassy::MongoODM::Repository(User)
end

conn = Glassy::MongoODM::Connection.new("mongodb://mongo", db_name)

repository = UserRepository.new(conn)

user = User.new(name: "My Name", birth_date: Time.local)

repository.save(user)

Development

Always run crystal spec before submiting code

Contributing

  1. Fork it (https://github.com/glassy-framework/glassy-mongo-odm/fork)
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create a new Pull Request

Contributors

About

Mongo ODM (Object Document Mapper) with repositories for crystal lang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages