Giter Site home page Giter Site logo

sam0x17 / mongo_orm Goto Github PK

View Code? Open in Web Editor NEW
32.0 6.0 6.0 206 KB

Mongo ORM: A simple ORM for using MongoDB with the crystal programming language, designed for use with Amber. Based loosely on Granite ORM. Supports Rails-esque models, associations and embedded documents.

License: MIT License

Crystal 99.11% Shell 0.89%
crystal-language orm mongo database-access amber-framework crystal-shard mongodb shards

mongo_orm's People

Contributors

alaaattya avatar mniak avatar sam0x17 avatar steffanperry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mongo_orm's Issues

Time.now undefined method

Hello

I found a bug when to create document, it seem problem on timestamp that use function Time.now which deprecated in crystal 0.33.

https://crystal-lang.org/api/0.33.0/Time.html

the message

Which expanded to:

 > 10 | if _id
 > 11 |   __run_before_update
 > 12 |   @updated_at = Time.now.to_utc
                             ^--
Error: undefined method 'now' for Time.class

Did you mean 'new'?

Not able to install mongo_orm

Failed git branch --list --column=never --contains 86c9e530c0ac980ed7b15e653746bc5b6f2527fc (no such commit 86c9e530c0ac980ed7b15e653746bc5b6f2527fc). Maybe a commit, branch or file doesn't exist?

install_linux_deps issue on antergos/arch linux

...
src/mongoc/mongoc-rand.c: In function ‘_mongoc_pseudo_rand_bytes’:
src/mongoc/mongoc-rand.c:33:5: warning: ‘RAND_pseudo_bytes’ is deprecated [-Wdeprecated-declarations]
     return RAND_pseudo_bytes(buf, num);
     ^~~~~~
In file included from /usr/include/openssl/e_os2.h:13,
                 from /usr/include/openssl/ossl_typ.h:19,
                 from /usr/include/openssl/rand.h:14,
                 from src/mongoc/mongoc-rand.c:26:
/usr/include/openssl/rand.h:47:1: note: declared here
 DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
 ^~~~~~~~~~~~~~~~~~
  CC       src/mongoc/libmongoc_priv_la-mongoc-sasl.lo
  CC       src/mongoc/libmongoc_1_0_la-mongoc-array.lo
src/mongoc/mongoc-stream-tls.c:100:1: error: variable ‘gMongocStreamTlsRawMethods’ has initializer but incomplete type
 static BIO_METHOD gMongocStreamTlsRawMethods = {
 ^~~~~~
src/mongoc/mongoc-stream-tls.c:101:4: warning: excess elements in struct initializer
    BIO_TYPE_FILTER,
    ^~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:101:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:102:4: warning: excess elements in struct initializer
    "mongoc-stream-tls-glue",
    ^~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:102:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:103:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_write,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:103:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:104:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_read,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:104:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:105:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_puts,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:105:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:106:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_gets,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:106:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:107:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_ctrl,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:107:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:108:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_create,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:108:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c:109:4: warning: excess elements in struct initializer
    _mongoc_stream_tls_bio_destroy
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-stream-tls.c:109:4: note: (near initialization for ‘gMongocStreamTlsRawMethods’)
src/mongoc/mongoc-stream-tls.c: In function ‘_mongoc_stream_tls_bio_create’:
src/mongoc/mongoc-stream-tls.c:134:5: error: dereferencing pointer to incomplete type ‘BIO’ {aka ‘struct bio_st’}
    b->init = 1;
     ^~
src/mongoc/mongoc-stream-tls.c: At top level:
src/mongoc/mongoc-stream-tls.c:100:19: error: storage size of ‘gMongocStreamTlsRawMethods’ isn’t known
 static BIO_METHOD gMongocStreamTlsRawMethods = {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [Makefile:2828: src/mongoc/libmongoc_priv_la-mongoc-stream-tls.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
src/mongoc/mongoc-ssl.c: In function ‘_mongoc_ssl_check_cert’:
src/mongoc/mongoc-ssl.c:253:16: warning: ‘ASN1_STRING_data’ is deprecated [-Wdeprecated-declarations]
                check = (char *)ASN1_STRING_data (name->d.ia5);
                ^~~~~
In file included from /usr/include/openssl/bn.h:31,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/ssl.h:50,
                 from src/mongoc/mongoc-ssl.c:24:
/usr/include/openssl/asn1.h:553:1: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^~~~~~~~~~~~~~~~~~
At top level:
src/mongoc/mongoc-ssl.c:515:1: warning: ‘_mongoc_ssl_thread_locking_callback’ defined but not used [-Wunused-function]
 _mongoc_ssl_thread_locking_callback (int         mode,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mongoc/mongoc-ssl.c:504:1: warning: ‘_mongoc_ssl_thread_id_callback’ defined but not used [-Wunused-function]
 _mongoc_ssl_thread_id_callback (void)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: Leaving directory '/home/sam/Desktop/workspace/crystal-mongo-orm/lib/mongo-c-driver-1.1.0'
make: *** [Makefile:3727: all-recursive] Error 1

Not working with crystal 0.26.1 - JSON::Type

Error target TesteCrystal failed to compile:
Error in src/TesteCrystal.cr:1: while requiring "mongo_orm"

require "mongo_orm"
^

in lib/mongo_orm/src/mongo_orm.cr:2: while requiring "./mongo_orm/*"

require "./mongo_orm/*"
^

in lib/mongo_orm/src/mongo_orm/document.cr:2: while requiring "./fields"

require "./fields"
^

in lib/mongo_orm/src/mongo_orm/fields.cr:4: undefined constant JSON::Type

  alias Type = JSON::Type | DB::Any
               ^~~~~~~~~~

Can't convert to JSON

After calling #to_json on a query result, i get an error:

no overload matches 'BSON::ObjectId#to_json' with type JSON::Builder

Am I doing something wrong or is this functionality not supported?

Disclaimer: I'm new to Crystal and Amber.

Can't import the library

while requiring "mongo-orm": can't find file'mongo-orm' is thrown.
Also tried importing just the "mongo" library, then: undefined constant Mongo::ORM::Document

How do you import this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.