Registry / database / raku-orm

raku-orm

JSON →
library3.1.2jsnpmunverified

A promise-based ORM for Riak built on the raku Riak client. Version 3.1.2 supports has-and-belongs-to-many, has-many/belongs-to, and has-one relationships with or without inverses. It uses automatic integer ID generation per class and saves each attribute separately to avoid accidental overwrites. This hobby project is not actively maintained and has no recent updates.

npm install raku-orm
INSTALL
IMPORT
SIG · RAKU-ORM
R
raku-orm
databasejavascriptv3.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RakuOrm
import RakuOrm from 'raku-orm'
const RakuOrm = require('raku-orm')
The package only provides a default export. It uses ESM exports but may work with require if you use a transpiler.
RakuOrm (side-effect import)
import 'raku-orm'
The README shows using import 'raku-orm' before defining classes that extend RakuOrm. This is a side-effect import that makes RakuOrm available globally.

Defines User and Post models with associations, saves instances, and loads attributes from Riak.

import 'raku-orm' class User extends RakuOrm { } User.schema = { first_name: 'String', last_name: 'String', username: 'String', email: 'String', password: 'String', habtm: [ { method: 'favorite_posts', model: 'Post' } ], has_many: [ { method: 'approved_articles', model: 'Post' } ] } class Post extends RakuOrm { } Post.schema = { title: 'String', body: 'String', views: 'Integer', habtm: [ { model: 'User', method: 'who_favorited', inverse_of: 'favorite_posts' } ], belongs_to: [ { model: 'User', method: 'approver', inverse_of: 'approved_articles' } ] } RakuOrm.init(Post) RakuOrm.init(User) async function example() { let user = new User() user.first_name = 'David' user.email = 'thirdreplicator@gmail.com' await user.save() let post = new Post() post.title = 'Example' post.body = 'Body text' post.approver_id = user.id await post.save() let loaded = new User(user.id) await loaded.load('first_name') console.log(loaded.first_name) } example()
Debug
Known issues
gotchaAttribute loading is explicit: only id is loaded by default. You must call load() with attribute names to load them.
fix
Use instance.load('first_name', 'last_name') to load specific attributes.
affects: >=3.0.0
breakingAssociation loading methods changed from user.posts() to user.load_posts() in version 3.0.0.
fix
Use load_posts() instead of posts() to load associated objects.
affects: >=3.0.0
deprecatedThe package is a hobby project and not actively maintained. No updates since 2017.
fix
Consider migrating to a more modern ORM or database solution.
affects: *
gotchaHaBTM relationships automatically create an ids array (e.g., 'favorite_posts_ids'). Set this array directly.
fix
Assign user.favorite_posts_ids = [postId1, postId2] to relate posts.
affects: *
gotchaRiak must be running and accessible. The raku client requires Riak connection configuration.
fix
Ensure Riak is configured and accessible, and that raku is properly initialized.
affects: *
Errors
Common errors & fixes
TypeError: RakuOrm is not a constructor
Forgetting to import RakuOrm or using wrong import syntax.
fix
Use 'import RakuOrm from 'raku-orm'' or 'import 'raku-orm' then class extends RakuOrm.
Error: Cannot find module 'raku-orm'
Package not installed.
fix
Run 'npm install raku-orm' in your project.
TypeError: user.load is not a function
Trying to load attributes before calling RakuOrm.init on the model class.
fix
Call 'RakuOrm.init(User)' after defining the schema.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
rakurequiredUnderlying Riak client used for all database operations
Agent activity
5 hits · last 30 days
node
4
Meta
1
Resources
raku-orm — npm install raku-orm · libregistry