Giter Club home page Giter Club logo

orange-orm's People

Contributors

aagejohansen avatar adlanelm avatar arnebjorgan avatar ashleyversvik avatar astroxslurg avatar lroal avatar marcbachmann avatar robertversvik 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  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  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  avatar  avatar  avatar  avatar

Watchers

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

orange-orm's Issues

SurrealDB support

Curious on your thoughts on supporting SurrealDB, ideally for surreal.js and surreal.node ๐Ÿคž

ANDing an array of filters gives sql error

const filter = db.foo.id.eq(1);
const rows = await db.foo.getMany(db.and( [filter] )):
//error: An expression of non-boolean type specified in a context where a condition is expected, near 'order'

IEqual gives incorrect sql on special characters

I run with getMany with filter on email column. This crashes when email has underscore. The generated sql looks like this:

select _user.id as s_user0,
_user.email as s_user1,
_user.password as s_user2,
_user.salt as s_user3,
_user.plan as s_user4,
_user.registered_date as s_user5,
_user.trial_until as s_user6,
_user.premium_until as s_user7,
_user.stripe_id as s_user8
from _user _user
where _user.email ILIKE '$1' order by _user.id

The code:
var emailFilter = userTable.email.iEqual('[email protected]');
return userTable.getMany(emailFilter).then(createAccount);

Support for on conflict clause

Hello, thanks for creating this library. The API looks really great for TS.

Curious if you would be open to adding support for on conflict clause for insert. It is quite convenient for handling upsert. Related docs in postgres manual.

Raw queries run outside of transaction

The query below creates a new connection instead of using exisiting transaction.
It happens only to raw queries, not model-updates.

await db.transaction(async (db) => {
  result = await db.query('select 1 as foo');
});

Polymorphic Associations

Hey, very interesting project ๐Ÿ™Œ

Curious if polymorphism is already possible or planned?

E.g. I have a table commenting which has commentable_type & commentable_id fields where type could be article and id the articles id

I'm currently finally evaluating an ORM for our project as things get a little unwieldy using mysql2 directly writing manual types & queries ๐Ÿฅด

Edit: maybe this discussion on polymorphic associations could be interesting drizzle-team/drizzle-orm#1051

column mapping value defaults to null/0 , resulting in pkey generation failure

I'm trying to get the postgresql generated primary key from Object.id. If I map the id column to Object.id:

Object.primaryColumn('id').string().as('id'); //OR
Object.column('id').numeric().as('id'),

The id value gets a default value which then is being inserted in the table even if i don't set it in the insert method. Is there a way to get the auto generated id that I'm missing? Please help~ Thank you!

document formulaDiscriminator

Perhaps change name to baseFilter.
Should accept: string | RawFilter | RawFilter[] | () => string | RawFilter | RawFilter[] | () => Promise<string | RawFilter | RawFilter[]> .

It would be a good idea to get db model dynamically when hosting in express as well.
Something like this:

express().disable('x-powered-by')
  .use(json({ limit: '100mb' }))
  .use(cors())
  .use('/rdb', validateToken)
  .use('/rdb', db.express((db, _req, _res) => {
    return db.map(x => ({
	order: x.order.baseFilter(() => {
          const customerId = Number.parseInt(req.headers.authorization.split(' ')[1]); //Bearer 2
          return db.order.customerId.eq(Number.parseInt(customerId));
	});
    })    
  }, {
    order: true
  })  
  .listen(3000, () => console.log('Example app listening on port 3000!'));

equivalent:

express().disable('x-powered-by')
  .use(json({ limit: '100mb' }))
  .use(cors())
  .use('/rdb', validateToken)
  .use('/rdb', db.express((db, _req, _res) => {

    const customerId = Number.parseInt(req.headers.authorization.split(' ')[1]); //Bearer 2
    const orderFilter = db.order.customerId.eq(Number.parseInt(customerId));

    return db.map(x => ({
	order: x.order.baseFilter(orderFilter)
    })    
  }, {
    order: true
  })  
  .listen(3000, () => console.log('Example app listening on port 3000!'));

..and when not in express (pure server):

const  someCustomerId = 2;

const dbRestricted = db.map(x => {
  const customerId = someCustomerId;
  const orderFilter = db.order.customerId.eq(Number.parseInt(customerId));

  return {
    order: x.order.baseFilter(orderFilter)
  };
});

GetFromDbById must use promise

NOT LIKE THIS:

var row = tryGetFromDbById.apply(null,arguments);
if (row === null)
throw("Row not found.")
return row;

db() resolve should memoize

When resolving db-connection dynamically, it should memoize (cache).
Otherwise you need to manually handle a singleton or end up creating a new pool for every call.
The connection string / object and options object should act as key for the dictionary cache.

So it should be sufficient to do this

export default map({
  db: (con) => con.mssql('somestring', {size: 10})      
});

instead of this:

let pool: rdb.Pool;

export default map({
  db: (con) => {
    if (pool)
      return pool;
    else {
      pool = con.mssql('somestring', {size: 10});
      return pool;
    }
  }
});

Inserts gives foreign key violation

var order = Order.insert('abcdef00-0000-0000-0000-000000000001');
var customer = Customer.insert('abcdef00-0000-0000-0000-000000000000')
customer.name = 'Paul';
order.customerId = customer.id;

It tries to insert order with customerId which is not exisiting yet.

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.