lemanschik / node-ottoman

Node.js ODM for Couchbase
https://ottomanjs.com/
Apache License 2.0
0 stars 0 forks source link

Did fork this before adopt usefull stuff and take over maintainance as package maintainance is needed #1

Open lemanschik opened 5 days ago

lemanschik commented 5 days ago

Main Issues

Need to create apis and refactor to esm asap this week.

References

Copy from old issue

add helpers

Ottoman accepts scopeName and collectionName while model accepts only scopeName

Disable All exports of the cjs module i mark this a case for migration to esm only as require('es-module') lands in node 22.x

Notes

https://ottomanjs.com/docs/basic/ottoman#defining-an-ottoman-instance mainly the example to use collections

https://github.com/couchbaselabs/node-ottoman/issues/639#issuecomment-1061010070

To query into array values use this way:

const where_exp = {
$any: {
$expr: [{ b: { $in: ‘block2’ } }],
$satisfies: { ‘b.field3’: {$eq: “xyz”} },
}
};
this will produce this valid N1Ql query
SELECT * FROM travel-sample.inventory.hotel WHERE ANY b IN block2 SATISFIES b.field3=“xyz” END
CREATE INDEX ix1 ON  mybucket.myscope.mycollection ( DISTINCT ARRAY e FOR e IN emails END);

SELECT *
FROM  mybucket.myscope.mycollection AS c
WHERE ANY e IN emails SATISFIES e = "xyz@abc.com" END;

Query builder syntax some thing in this lines

const where_exp = {
$any: {
$expr: [{ e: { $in: emails } }],
$satisfies: { e: {$eq: “xyz@abc.com”} },
}
};
lemanschik commented 5 days ago
 console.log(1)
    await connect("couchbase://localhostdefault-bucket@appasa:appappasdasd",{  });
    console.log(2)
  const User = model('User', { name: String },{ 
    collectionName: "_default",scopeName: "_default"
  });
  console.log(3)
  const user = new User({ name: 'Jane Doe' });
  console.log(4,user)
  await start(); // This should throw if something like collection and scope not exists
  console.log(5)
  await user.save();
  console.log(6)
  console.log('Nice Job!');

  await close();