Kirlovon/aloedb

Could you add "findMany()" or "findOne()" case sensitive=true optional argument, by default false?

salemalem opened this issue · 3 comments

This works!

await db.insertOne({title: "how to use linux", body: "go to linux.org"});
let result = await db.findMany({ title: "how to use linux" });
console.log(result);

But as soon as I change linux in findMany to Linux (capitalization), it can't find it.
I know this isn't a bug, but could you add case insensitive option/functionality?

For my future thoughts, do you know how can I implement a smart or fizz buzz search, so even when I search for "Linux", it gives me all Linux tutorials/articles?

This English version is intended to keep this issue understandable to the international community.
Below, Russian)

Я понимаю это не баг. Но было бы круто если бы ты добавил аргумент в функции findMany и findOne как case_sensitive=true/false. В будующем как я могу добавить умный поиск или же физ баз который ищет через расстояние левенштейна? Извини что спамлю :) Пойму если достал уже своими проблемами ;D

db.insertOne({key: 1, value: "one"})
но
db.insertOne({1: "one"}) не работает. Тоесть не подходит для aloe.
Я еще заметил что findOne({key: 1}) нужно писать в то время как casualdb поддерживает db.get(1) сразу.
Это я про то что key, value это тоже же занимает память.

I do not plan to add a case sensitive switch for search queries. Same thing can be done in these ways:

await db.insertOne({ text: 'sOmE TeXt'});

// Using regular expressions
await db.findOne({
	text: new RegExp('some text', 'i')
});

// Using search function
await db.findOne({
	text: (value: any) => value.toLowerCase() === 'some text'
});

You can also use regular expressions for smart searches:

await db.insertOne({ title: 'How To Use Linux?' });
await db.insertOne({ title: 'Most popular linux distributions' });

const found = await db.findMany({
	title: new RegExp('linux', 'i')
});

console.log(found); // [ { title: "How To Use Linux?" }, { title: "Most popular linux distributions" } ]

Можешь добавить это в документацию?