alfateam / orange-orm Goto Github PK
View Code? Open in Web Editor NEWThe ultimate ORM for Node and Typescript
Home Page: https://orange-orm.io
License: ISC License
The ultimate ORM for Node and Typescript
Home Page: https://orange-orm.io
License: ISC License
Use options object
Curious on your thoughts on supporting SurrealDB, ideally for surreal.js and surreal.node ๐ค
This error occurs in v1.6.5 - v1.6.7
It is enabled for 16.0 SP04
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'
Caused by missing matches method on deleteCommand.
Sorry I'm on phone right now so just referencing this right now drizzle-team/drizzle-orm#1426
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);
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.
Hello, this project seems promising and I was looking through the docs and I saw this property "lines: true" in almost every query, I want to know what is it for?
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');
});
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
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!
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)
};
});
typical in a readonly scenario
//This does not work. Returns orders with no lines.
var filter;
var strategy = {lines: null};
order.getMany(filter, strategy);
//This works. Returns orders WITH lines
order.getMany(filter);
getChangeSet crashes
might be user fault
The date 2022-09-29T06:36:50.027Z converts to 2022-09-29T08:36:50.27+02:00.
This is probably caused by pad2 when milliseconds part is less than 10.
Using pad3 instead will solve this problem.
const rows = await db.foo.getMany(db.and( [] )):
console.dir(rows.length); //0
it returns an empty array instead of the rows.
column filters
raw sql filter
any
all
none
combining
NOT LIKE THIS:
var row = tryGetFromDbById.apply(null,arguments);
if (row === null)
throw("Row not found.")
return row;
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;
}
}
});
row.delete(optionalStrategy)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.