KiokuDB::Util(3pm)

πŸ“¦
version 0.57 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– KiokuDB::Util πŸ’–

okay so bestie, welcome to KiokuDB::Util β€” that's a 3pm man page, in case you were wondering, from the User Contributed Perl Documentation collection ✨ It's literally just a lil grab-bag of helper functions for working with KiokuDB, and it is so useful, I'm obsessed 🫢


✨ VERSION ✨

version 0.57 πŸ’…


🌸 SYNOPSIS 🌸

use KiokuDB::Util qw(set weak_set);

my $set = set(@objects); # create a transient set

my $weak = weak_set(@objects); # to avoid circular refs

like. look at that. two lines and you're already slaying πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This module provides various helper functions for working with KiokuDB. that's it, that's the whole vibe β€” it's giving "utility belt" energy, no cap πŸ”₯


πŸŽ€ EXPORTS πŸŽ€

okay so here's the tea, one bullet at a time πŸ‘‘

dsn_to_backend $dsn, %args

Tries to parse $dsn, load the backend, and invoke "new" on it. fr fr, that's the whole job.

It's used by "connect" in KiokuDB and by the various command line interfaces. so if you've ever wondered who's behind the curtain on those, hi, it's this function πŸ’–

set

weak_set

These two are besties and they do the same lil dance: instantiate a Set::Object or a Set::Object::Weak from the arguments, and then create a KiokuDB::Set::Transient with the result ✨

(so yes, set gives you the regular one and weak_set gives you the weak one β€” that's the difference, periodt 🌸)

import_yaml $kiokudb, @files_or_dirs

Loads YAML files with MooseX::YAML into the specified KiokuDB directory in a single transaction πŸ”₯ and if you hand it a directory instead of a file, it will be searched recursively for files with a ".yml" extension. so thorough. so iconic.

The YAML files can contain multiple documents, with each document treated as an object. and here's the cute part: if the YAML file contains a single non blessed array or hash, then that structure will be dereferenced as part of the arguments to "insert" πŸŽ€

Here's an example of an array of objects, plus a custom tag alias to make authoring the YAML file a lil easier for you:

%YAML 1.1
%TAG ! !MyFoo::
---
- !User
  id:        foo
  real_name: Foo Bar
  email:     foo@myfoo.com
  password:  '{cleartext}test123'

and you can use a hash to specify custom IDs, like so:

%YAML 1.1
---
the_id: !Some::Class
    attr: moose

see? custom IDs. main character energy πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Yuval Kogman <nothingmuch@woobling.org> 🫢


This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. πŸ’–


and that's the whole page, bestie!! this was KiokuDB::Util, documented for perl v5.34.0, dated 2022-05-23 β€” ty for coming to my ted talk, go forth and build transient sets responsibly πŸŒΈβœ¨πŸ’œ

πŸ“¦ where this page comes from