-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Library Enrichment Proposal (codename: Nekdis) #188
base: main
Are you sure you want to change the base?
Conversation
This change was made so the draft pull request can be open
As of Nekdis v0.8 Vector Similarity Search was added, would be great to get some feedback specially on the syntax used. |
Nekdis v0.10 brings some desired changes like reduce clutter saved and better api for modules, the biggest change however is the change from I will be working on bringing all the files to this pull request during this week but i would like to point people who are reading this PR to the issues i created on the Nekdis repository since they are really important when it comes to new features. The most important issues are Didas-git/Nekdis#6 which discusses the idea of a new entire relation system now that redis graph eol was announced, and Didas-git/Nekdis#10 which talks about a more front on/no hidden behaviour approach when it comes to indexing data. |
This is experimental and the PR is still a draft
V0.12 ChangelogThis is one of the biggest changes in a while and im really proud of it, it brings lots of features, but i will also combine the 0.11 changelog here since i didn't write one previously. ExamplesI have worked on a example that takes advantage of a lot of the new features, it is a simple api that uses nekdis as its database and you can find its repository here. The table example was also slightly updated. Array of objects!Array of objects are now fully supported in both SchemaNew typeIn v0.12 i added the New options
New PropertiesText
String
|
This is exactly the kind of thing I'm looking for. It brings better TypScript types which I need to make sure that I don't miss a required property. It also allows for better intellisense and TypeScript errors when I fetch a document. 👍 from me. |
V0.13 Changelog
RelationsAs of Nekdis 0.13 a new option called As for the functionality of the relation script itself it is divided into 2 categories each one with its sub categories. Creating relationsThere are 2 commands to create relations
Where:
First stepThe first step of creating a relation is creating the key where all the metadata will be saved, the type of the key can be either JSON or HASH depending on the command you use. Second StepThe second step is to append the id to the set that stores all the relations. Internally all it does is Getting all the relationsThe script also provides you a The syntax is:
Where:
This is easier to see if you look at the cli examples. How it worksThe first step is to get all the omitted ids from the set using Then we process them by fetching them, getting the Redis-cli ExampleLets setup 2 different users and create a relation between them with some metadata JSON.SET user:1 $ '{"name": "DidaS"}'
JSON.SET user:2 $ '{"name": "Leibale"}'
FCALL JSONCR 3 user:1 user:2 user:contacts:1 contacts '{"company": "Redis"}' After running this you will see 2 new keys on your database: A JSON key called {
"in": "user:1",
"out": "user:2",
"company": "Redis"
} And a set called To fetch all the relations you can run the following FCALL JSONGR 1 user:1 contacts Which for this example will return [
{
"name": "Leibale"
}
] You can note that metadata is not appended to the returning object, this is because metadata only exists so you can leverage An example of this would be: FT.CREATE exampleIdx ON JSON PREFIX 1 user:contacts: SCHEMA $.in AS in TAG $.out AS out TAG $.company AS company TEXT And then we want to search all contacts of user:1 that work on redis FT.SEARCH exampleIdx '@in:{user\:1} @company:redis' Nekdis exampleThis is a direct translation of the cli example into nekdis syntax with a bonus (explained on the comments) const userSchema = client.schema({
name: "string",
contacts: {
type: "relation",
schema: "self",
index: true,
// Meta could be another schema just like the properties in an object type
meta: {
company: "text"
}
}
});
const userModel = client.model("User", userSchema);
// This will also create the relation indexes to be used in the constrains
await userModel.createIndex();
// Im not using "createAndSave" so i can have the document without having to create and then fetch
const user1 = userModel.create({
name: "DidaS"
});
const user2 = userModel.create({
name: "Leibale"
});
const user3 = userModel.create({
name: "Webstrand"
});
await userModel.save(user1);
await userModel.save(user2);
await userModel.save(user3);
// Im passing the record id just to exemplify that you can use either the document or an id/key
await userModel.relate(user1).to(user2.$record_id).as("contacts").with({ company: "Redis" }).exec();
await userModel.relate(user1).to(user3).as("contacts").with({ company: "Unknown" }).exec();
await userModel.get(user1.$record_id, { withRelations: true });
/*
JSONDocument {
name: "DidaS",
contacts: [
JSONDocument { name: "Leibale" },
JSONDocument { name: "Webstrand" }
]
}
*/
await userModel.get(user1.$record_id, {
withRelations: true,
relationsConstrain: {
contacts: (search) => search.where("in").eq(userModel.sanitize(user1.$record_id)).and("company").eq("redis")
}
})
/*
JSONDocument {
name: "DidaS",
contacts: [
JSONDocument { name: "Leibale" }
]
}
*/
// This is what the search on the example returns, the one above is what Nekdis does to make it better for the user
await userModel.get(user1.$record_id, {
withRelations: true,
returnMetadataOverRelation: true,
relationsConstrain: {
contacts: (search) => search.where("in").eq(userModel.sanitize(user1.$record_id)).and("company").eq("redis")
}
})
/*
JSONDocument {
name: "DidaS",
contacts: [
JSONDocument {
company: "Redis",
in: "Nekdis:V1:User:8cb985f8-2430-49a3-85a2-e57883d4fe45",
out: "Nekdis:V1:User:49d110c0-14b0-4965-a27b-78b3480daa47"
}
]
}
*/ InstallationThis update is available as a beta version on npm, i will post a comment when i post it as the stable version
Quality of lifeThere were some major quality of life improvements when it comes to the types, they should be more accurate and easier to understand now. For the ones who might be interested in contributing, i improved some of the internal naming so now it should be easier to understand the type transformations Fixes
Know BugsIn some scenarios you might get a typescript error saying the types are not compatible when they are, this is an issue regarding mapped types that will be fixed in TS 5.3 |
V0.13.1 Changelog
Final notes0.13 will be made stable in 2/3 days after i merge it in this PR, i will also edit the previous changelog to correct the examples that are wrong (lack sanitization) |
V0.13.2 -> V0.13.4 Changelog
|
The sole purpose of this pull request is to show this proposal to more people and gather community feedback about it.
Me and @guyroyse already had some discussions about the proposal and i am aware that there is a lot that can be improved/changed and that even then the proposal might not be fully implemented, but the most important thing is to find what the developers and community that use redis-om want and thats why we want to know what features you guys like the most and would like to see in redis-om and which ones you don't like, we want to ear your feedback about both the current redis-om@beta and the proposal.
This proposal includes some new key features like, tuples, other rarray types, references, default values, required fields, custom methods and much more.
All the information about this proposal can be found in its repository.
Feel free to contact any of us here or on the redis discord.
Fixes:
#25 #28 #44 #54 #55 #66 #69 #120 #141 #184