[ANN] Datasource (ds) — A modern inline replacement for Lasso 9

classic Classic list List threaded Threaded
39 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
Hello all,

I'm pleased to announce the public release of Datasource (ds).

For those of you that weren't at LDC, it's a modern day replacement for
inline — it's very fast in terms of performance and extremely effecient in
terms of code. It's also very mature, feature rich and fully documented.

You can install it from here: https://github.com/zeroloop/ds

And read the documentation here:
https://github.com/zeroloop/ds/wiki/Introduction

Admittedly this isn't a January release as announced at LDC, but in terms
of time frames it will have to do. Time permitting, I'll try and get an
article done covering real world usage, performance comparisons and more
useful examples.

Open to any comments, suggestions or questions...

Thanks!

Ke

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Richard Taubo
On Dec 2, 2013, at 4:16 PM, Ke Carlton <[hidden email]> wrote:

> Hello all,
>
> I'm pleased to announce the public release of Datasource (ds).

That looks really nice and clean; looking forward to trying it out!
Congratulations and thanks! :-)

Richard Taubo

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Jonathan Guthrie-3
In reply to this post by Ke Carlton-3
On Dec 2, 2013, at 10:16 AM, Ke Carlton <[hidden email]> wrote:

> I'm pleased to announce the public release of Datasource (ds).
>
> For those of you that weren't at LDC, it's a modern day replacement for
> inline — it's very fast in terms of performance and extremely effecient in
> terms of code. It's also very mature, feature rich and fully documented.

Thanks for sharing this Ke - it's some great code, love using it myself :)


Jono

----------------------------
Jonathan Guthrie
[hidden email]
@iamjono
LassoSoft Inc.
AIM Chatroom: lassochat
IRC/freenode #lasso


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Jolle Carlestam-2
In reply to this post by Ke Carlton-3
2 dec 2013 kl. 16:16 skrev Ke Carlton <[hidden email]>:

> Hello all,
>
> I'm pleased to announce the public release of Datasource (ds).
>
> For those of you that weren't at LDC, it's a modern day replacement for
> inline — it's very fast in terms of performance and extremely effecient in
> terms of code. It's also very mature, feature rich and fully documented.
>

I've had the privilege to be allowed to dive into DS for some time now. I can vouch for it as being a very handy tool for any DB interaction.
Here's a small example on how efficient it is to use:

Prepare a DS object with database and table:
local(emailtbl= ds(::mydatabase.email))

Add a record:
#emailtbl -> addrow(#emailmap)

Grab a field from a record:
#emailtbl -> getrow(#email_id) -> find(:: email)

Update a record:
#emailtbl -> updaterow(map(::email = '[hidden email]'), #email_id)

This is four lines of code that creates, finds and updates a record. Not only is the code efficient. It also performs way faster than inlines.


You can also define types that can be used for DB or table access directly:
define ds_mydb() => ds(:: mydatabase)
define ds_mydb_email() => dsyotem -> table(::email)

The above definition goes where you have your other custom types and methods defined.
Usage:
ds_mydb_email -> getrow(#email_id)

or set it to a local and then immediately retrieve some value from the created record. Like the autoincremented id value:
local(
        emailrow = ds_mydb_email -> addrow(#emailmap),
        ref_id = #emailrow -> find(::ref_id)
)


There's much more that can be done with DS. See this as a teaser. And yet another reason why Lasso 9 rocks.

HDB
Jolle

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
In reply to this post by Jonathan Guthrie-3
Nice — you may want to grab the latest version if you haven't done for a
while.

It supports local joins like the below and has had a few bug fixes applied.

local(related_rows) = #resultset->find(::parent_id = #parent_id)


Ke

On 2 December 2013 16:10, Jonathan Guthrie <[hidden email]> wrote:
>
>
> Thanks for sharing this Ke - it's some great code, love using it myself :)
>
> Jono
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
In reply to this post by Jolle Carlestam-2
I'd like to also highlight and thank Jolle for the great contribution made
in terms of feedback, questions and discovery.

His questions on real world use have helped DS evolve — "How can I do x" is
a very powerful question.

The more people pick up and use DS the faster DS will evolve — as will your
code.

The learning curve is not steep, less so if you're familiar with SQL
statements and Query Expressions — if you're not familiar with Query
Expressions here is an excuse to learn them!

Ke

On 2 December 2013 16:11, Jolle Carlestam <[hidden email]> wrote:

>
> I've had the privilege to be allowed to dive into DS for some time now. I
> can vouch for it as being a very handy tool for any DB interaction.
>
> There's much more that can be done with DS. See this as a teaser. And yet
> another reason why Lasso 9 rocks.
>
> HDB
> Jolle
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
In reply to this post by Richard Taubo
Thanks Richard, I look forward to any feedback...

On 2 December 2013 15:49, Richard Taubo <[hidden email]> wrote:

>
> That looks really nice and clean; looking forward to trying it out!
> Congratulations and thanks! :-)
>
> Richard Taubo
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior
In reply to this post by Ke Carlton-3
Hi Ke:

This looks awesome. Can you clarify if the comparison is between  a standard inline or an inline that uses -sql?

It will also be interesting to see how this compares to the performance of the table objects that we create for each table. I am guessing we can combine the two.

Deco


On Dec 2, 2013, at 10:05 AM, Ke Carlton <[hidden email]> wrote:

> I'd like to also highlight and thank Jolle for the great contribution made
> in terms of feedback, questions and discovery.
>
> His questions on real world use have helped DS evolve — "How can I do x" is
> a very powerful question.
>
> The more people pick up and use DS the faster DS will evolve — as will your
> code.
>
> The learning curve is not steep, less so if you're familiar with SQL
> statements and Query Expressions — if you're not familiar with Query
> Expressions here is an excuse to learn them!
>
> Ke
>
> On 2 December 2013 16:11, Jolle Carlestam <[hidden email]> wrote:
>
>>
>> I've had the privilege to be allowed to dive into DS for some time now. I
>> can vouch for it as being a very handy tool for any DB interaction.
>>
>> There's much more that can be done with DS. See this as a teaser. And yet
>> another reason why Lasso 9 rocks.
>>
>> HDB
>> Jolle
>>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
Hello Deco,

All benchmarks displayed use SQL statements. But DS also out performs
inline in terms of classic inlines.

To put it politely; I suspect it will destroy your table objects in terms
of performance.

In all seriousness, based on what knowledge I've aquired of your system
from the list I suspect the most useful / suitable part of DS for you is
activerow: https://github.com/zeroloop/ds/wiki/Active-Row — it allows you
to create types that represent rows in a table (without the typical
performance overheads) and with them in an OOP fashion.

That area of the docs could do with a few more examples but overall it's
complete.

Ke

On 2 December 2013 17:16, deco rior <[hidden email]> wrote:

> Hi Ke:
>
> This looks awesome. Can you clarify if the comparison is between  a
> standard inline or an inline that uses -sql?
>
> It will also be interesting to see how this compares to the performance of
> the table objects that we create for each table. I am guessing we can
> combine the two.
>
> Deco

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior
Hi, Ke:

This looks great! The performance graphs look awesome. I actually think we will use all of it and not just Active-Row. We did some work on collections with out objects, but was not very elegant.

I have just started to delve into the documentation. But would like some ideas on the best way to do the following or if they are in there already

There are a few methods that we actually make quite a bit of use of.

1. Clone. This creates a copy of the object that can then be easily updated. Very useful when we just want to create multiple similar records from a record with a change in one or two fields.
2. Archive. This allows us to define an archive table named tableName_archive. This allows us to write out a copy of the record as an audit before making changes to the object.
3. Values. This outputs all the values in the object as a nice table for development purposes
4. We also keep  "code" and "error"  as instance variables so we can interrogate the insert statement, and easily identify an error conditions. These are updated within the object but not part of the table structure (of course)

Deco

On Dec 2, 2013, at 10:38 AM, Ke Carlton <[hidden email]> wrote:

> Hello Deco,
>
> All benchmarks displayed use SQL statements. But DS also out performs
> inline in terms of classic inlines.
>
> To put it politely; I suspect it will destroy your table objects in terms
> of performance.
>
> In all seriousness, based on what knowledge I've aquired of your system
> from the list I suspect the most useful / suitable part of DS for you is
> activerow: https://github.com/zeroloop/ds/wiki/Active-Row — it allows you
> to create types that represent rows in a table (without the typical
> performance overheads) and with them in an OOP fashion.
>
> That area of the docs could do with a few more examples but overall it's
> complete.
>
> Ke
>
> On 2 December 2013 17:16, deco rior <[hidden email]> wrote:
>
>> Hi Ke:
>>
>> This looks awesome. Can you clarify if the comparison is between  a
>> standard inline or an inline that uses -sql?
>>
>> It will also be interesting to see how this compares to the performance of
>> the table objects that we create for each table. I am guessing we can
>> combine the two.
>>
>> Deco
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
Hi Deco, responses below.

On 3 December 2013 04:12, deco rior <[hidden email]> wrote:

>
> 1. Clone. This creates a copy of the object that can then be easily
> updated. Very useful when we just want to create multiple similar records
> from a record with a change in one or two fields.
>

Active Row has ->asnew which returns a copy of the row with a null keyvalue
(from there you can update, save etc). Every ds_row and activerow also have
->asmap which returns all of the rows data as a map.


> 2. Archive. This allows us to define an archive table named
> tableName_archive. This allows us to write out a copy of the record as an
> audit before making changes to the object.
>

You can easily achieve this like so:

#row->ds->addrow(#row->table + '_archive', #row->asmap)


> 3. Values. This outputs all the values in the object as a nice table for
> development purposes
>

See ->asmap or ->asarray, typically combined ldebug or similar.


> 4. We also keep  "code" and "error"  as instance variables so we can
> interrogate the insert statement, and easily identify an error conditions.
> These are updated within the object but not part of the table structure (of
> course)
>

If you want custom error handle simply override the ->save methods in your
type, see here:
https://github.com/zeroloop/ds/wiki/Active-Row#changing-activerow-behavior—
your master type can simply inherit activerow and each of your types
can
in turn inherit from that.

Hope that helps...

Ke

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
In reply to this post by Ke Carlton-3
Hello all,

Please see the below URL for an example shopping cart using DS:

https://gist.github.com/Ke-/7784863


As you can see, there's very few lines of codes.

Ke

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Paul Melia-4
Ke,

Very nice!

I have been updating a site to Lasso 9 that started with Lasso 3.6 and hadn't been revised since Lasso 8.
But I think I'll be going through now and updating to DS - it looks that compelling.

Paul

On Dec 4, 2013, at 8:58 AM, Ke Carlton <[hidden email]> wrote:

> Hello all,
>
> Please see the below URL for an example shopping cart using DS:
>
> https://gist.github.com/Ke-/7784863
>
>
> As you can see, there's very few lines of codes.
>
> Ke
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior
In reply to this post by Ke Carlton-3
Agreed...nice

We installed DS last night. Very clean and fast. Good timing on your part!

I did have a question thought. Mostly due to my lack of knowledge of lasso 9

You have this

public ds => ds(::example.carts)

But we need the name of the database to be a variable

What is the syntax for that?


On Dec 4, 2013, at 6:58 AM, Ke Carlton <[hidden email]> wrote:

> Hello all,
>
> Please see the below URL for an example shopping cart using DS:
>
> https://gist.github.com/Ke-/7784863
>
>
> As you can see, there's very few lines of codes.
>
> Ke
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
Hello Deco,

See here:
https://github.com/zeroloop/ds/wiki/Working-with-data-sources-%E2%80%94-ds#defining-ds-connections

In the real world I would have something like this:

define store_ds => ds(::mysqlds,'127.0.0.1',::store.products,'root','')

define cart => type {
    parent activerow
    public ds => store_ds->table(::carts)
}

define cart_item => type {
    parent activerow
    public ds => store_ds->table(::cart_items)
}


Or possibly a cart_ds and cart_items definition like so:

define cart_ds => store_ds->table(::carts)


It would depend on the situation and environment — but obviously in
examples things have to be kinda simplified.

I would NEVER use varibles directly — there is simply no need and they only
muddy the water. You can add logic into ds definitions if required:


define store_ds => {
server_name >> 'dev'
? return ds(::mysqlds,'127.0.0.1',::store.products,'root','')
| return ds(::mysqlds,'10.0.0.1',::store.products,'live','megapassword')
}


You can do things like this though:

local(myds) = ds(::mysqlds,'127.0.0.1',::store.products,'root','')
#myds->addrow(...) etc...


But typically you would want to reuse a datasource so just define it one
and be done with it. The cool thing about inherited ds definitions is that
you only need to update your base definition and everything else follows
suit...

Ke

On 4 December 2013 14:15, deco rior <[hidden email]> wrote:

> You have this
>
> But we need the name of the database to be a variable
>
> What is the syntax for that?
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior
Hi, Ke:

Thanks for the examples, these really help me understand more.

However, the database name in our application has to be a variable. Do I need to use the longer syntax? This would actually be pretty impractical based on our current code, since we are using a global variable for the database name.



On Dec 4, 2013, at 7:28 AM, Ke Carlton <[hidden email]> wrote:

> Hello Deco,
>
> See here:
> https://github.com/zeroloop/ds/wiki/Working-with-data-sources-%E2%80%94-ds#defining-ds-connections
>
> In the real world I would have something like this:
>
> define store_ds => ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>
> define cart => type {
>    parent activerow
>    public ds => store_ds->table(::carts)
> }
>
> define cart_item => type {
>    parent activerow
>    public ds => store_ds->table(::cart_items)
> }
>
>
> Or possibly a cart_ds and cart_items definition like so:
>
> define cart_ds => store_ds->table(::carts)
>
>
> It would depend on the situation and environment — but obviously in
> examples things have to be kinda simplified.
>
> I would NEVER use varibles directly — there is simply no need and they only
> muddy the water. You can add logic into ds definitions if required:
>
>
> define store_ds => {
> server_name >> 'dev'
> ? return ds(::mysqlds,'127.0.0.1',::store.products,'root','')
> | return ds(::mysqlds,'10.0.0.1',::store.products,'live','megapassword')
> }
>
>
> You can do things like this though:
>
> local(myds) = ds(::mysqlds,'127.0.0.1',::store.products,'root','')
> #myds->addrow(...) etc...
>
>
> But typically you would want to reuse a datasource so just define it one
> and be done with it. The cool thing about inherited ds definitions is that
> you only need to update your base definition and everything else follows
> suit...
>
> Ke
>
> On 4 December 2013 14:15, deco rior <[hidden email]> wrote:
>
>> You have this
>>
>> But we need the name of the database to be a variable
>>
>> What is the syntax for that?
>>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
Just use one of the other signatures, ie:

ds($database,'table')

But I asure you — you do not need to use variable names for databases. You
just need to wrap you head around DS a little better...

Ke


On 4 December 2013 15:15, deco rior <[hidden email]> wrote:

> Hi, Ke:
>
> Thanks for the examples, these really help me understand more.
>
> However, the database name in our application has to be a variable. Do I
> need to use the longer syntax? This would actually be pretty impractical
> based on our current code, since we are using a global variable for the
> database name.
>
>
>
> On Dec 4, 2013, at 7:28 AM, Ke Carlton <[hidden email]> wrote:
>
> > Hello Deco,
> >
> > See here:
> >
> https://github.com/zeroloop/ds/wiki/Working-with-data-sources-%E2%80%94-ds#defining-ds-connections
> >
> > In the real world I would have something like this:
> >
> > define store_ds => ds(::mysqlds,'127.0.0.1',::store.products,'root','')
> >
> > define cart => type {
> >    parent activerow
> >    public ds => store_ds->table(::carts)
> > }
> >
> > define cart_item => type {
> >    parent activerow
> >    public ds => store_ds->table(::cart_items)
> > }
> >
> >
> > Or possibly a cart_ds and cart_items definition like so:
> >
> > define cart_ds => store_ds->table(::carts)
> >
> >
> > It would depend on the situation and environment — but obviously in
> > examples things have to be kinda simplified.
> >
> > I would NEVER use varibles directly — there is simply no need and they
> only
> > muddy the water. You can add logic into ds definitions if required:
> >
> >
> > define store_ds => {
> > server_name >> 'dev'
> > ? return ds(::mysqlds,'127.0.0.1',::store.products,'root','')
> > | return ds(::mysqlds,'10.0.0.1',::store.products,'live','megapassword')
> > }
> >
> >
> > You can do things like this though:
> >
> > local(myds) = ds(::mysqlds,'127.0.0.1',::store.products,'root','')
> > #myds->addrow(...) etc...
> >
> >
> > But typically you would want to reuse a datasource so just define it one
> > and be done with it. The cool thing about inherited ds definitions is
> that
> > you only need to update your base definition and everything else follows
> > suit...
> >
> > Ke
> >
> > On 4 December 2013 14:15, deco rior <[hidden email]> wrote:
> >
> >> You have this
> >>
> >> But we need the name of the database to be a variable
> >>
> >> What is the syntax for that?
> >>
> >>
> >
> > #############################################################
> > This message is sent to you because you are subscribed to
> >  the mailing list Lasso
> > [hidden email]
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>   the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior

On Dec 4, 2013, at 8:19 AM, Ke Carlton <[hidden email]> wrote:

> Just use one of the other signatures, ie:
>
> ds($database,'table')

ok

>
> But I asure you — you do not need to use variable names for databases. You
> just need to wrap you head around DS a little better...

Ok, but in our application each customer has their own database instance. We have ~300 customer using the application with the same code base. When a customer logs in their database gets saved as a variable. How else would we do this?

Our setup requires no code changes.

Deco



>
> Ke
>
>
> On 4 December 2013 15:15, deco rior <[hidden email]> wrote:
>
>> Hi, Ke:
>>
>> Thanks for the examples, these really help me understand more.
>>
>> However, the database name in our application has to be a variable. Do I
>> need to use the longer syntax? This would actually be pretty impractical
>> based on our current code, since we are using a global variable for the
>> database name.
>>
>>
>>
>> On Dec 4, 2013, at 7:28 AM, Ke Carlton <[hidden email]> wrote:
>>
>>> Hello Deco,
>>>
>>> See here:
>>>
>> https://github.com/zeroloop/ds/wiki/Working-with-data-sources-%E2%80%94-ds#defining-ds-connections
>>>
>>> In the real world I would have something like this:
>>>
>>> define store_ds => ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>>
>>> define cart => type {
>>>   parent activerow
>>>   public ds => store_ds->table(::carts)
>>> }
>>>
>>> define cart_item => type {
>>>   parent activerow
>>>   public ds => store_ds->table(::cart_items)
>>> }
>>>
>>>
>>> Or possibly a cart_ds and cart_items definition like so:
>>>
>>> define cart_ds => store_ds->table(::carts)
>>>
>>>
>>> It would depend on the situation and environment — but obviously in
>>> examples things have to be kinda simplified.
>>>
>>> I would NEVER use varibles directly — there is simply no need and they
>> only
>>> muddy the water. You can add logic into ds definitions if required:
>>>
>>>
>>> define store_ds => {
>>> server_name >> 'dev'
>>> ? return ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>> | return ds(::mysqlds,'10.0.0.1',::store.products,'live','megapassword')
>>> }
>>>
>>>
>>> You can do things like this though:
>>>
>>> local(myds) = ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>> #myds->addrow(...) etc...
>>>
>>>
>>> But typically you would want to reuse a datasource so just define it one
>>> and be done with it. The cool thing about inherited ds definitions is
>> that
>>> you only need to update your base definition and everything else follows
>>> suit...
>>>
>>> Ke
>>>
>>> On 4 December 2013 14:15, deco rior <[hidden email]> wrote:
>>>
>>>> You have this
>>>>
>>>> But we need the name of the database to be a variable
>>>>
>>>> What is the syntax for that?
>>>>
>>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso
>>> [hidden email]
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>  the mailing list Lasso
>> [hidden email]
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

decorior
In reply to this post by Ke Carlton-3

On Dec 4, 2013, at 8:19 AM, Ke Carlton <[hidden email]> wrote:

> Just use one of the other signatures, ie:
>
> ds($database,'table')
>

Doesn't this one assume I am using lasso admin? This will not work either actually. performance and setup issues.



> But I asure you — you do not need to use variable names for databases. You
> just need to wrap you head around DS a little better...
>
> Ke
>
>
> On 4 December 2013 15:15, deco rior <[hidden email]> wrote:
>
>> Hi, Ke:
>>
>> Thanks for the examples, these really help me understand more.
>>
>> However, the database name in our application has to be a variable. Do I
>> need to use the longer syntax? This would actually be pretty impractical
>> based on our current code, since we are using a global variable for the
>> database name.
>>
>>
>>
>> On Dec 4, 2013, at 7:28 AM, Ke Carlton <[hidden email]> wrote:
>>
>>> Hello Deco,
>>>
>>> See here:
>>>
>> https://github.com/zeroloop/ds/wiki/Working-with-data-sources-%E2%80%94-ds#defining-ds-connections
>>>
>>> In the real world I would have something like this:
>>>
>>> define store_ds => ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>>
>>> define cart => type {
>>>   parent activerow
>>>   public ds => store_ds->table(::carts)
>>> }
>>>
>>> define cart_item => type {
>>>   parent activerow
>>>   public ds => store_ds->table(::cart_items)
>>> }
>>>
>>>
>>> Or possibly a cart_ds and cart_items definition like so:
>>>
>>> define cart_ds => store_ds->table(::carts)
>>>
>>>
>>> It would depend on the situation and environment — but obviously in
>>> examples things have to be kinda simplified.
>>>
>>> I would NEVER use varibles directly — there is simply no need and they
>> only
>>> muddy the water. You can add logic into ds definitions if required:
>>>
>>>
>>> define store_ds => {
>>> server_name >> 'dev'
>>> ? return ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>> | return ds(::mysqlds,'10.0.0.1',::store.products,'live','megapassword')
>>> }
>>>
>>>
>>> You can do things like this though:
>>>
>>> local(myds) = ds(::mysqlds,'127.0.0.1',::store.products,'root','')
>>> #myds->addrow(...) etc...
>>>
>>>
>>> But typically you would want to reuse a datasource so just define it one
>>> and be done with it. The cool thing about inherited ds definitions is
>> that
>>> you only need to update your base definition and everything else follows
>>> suit...
>>>
>>> Ke
>>>
>>> On 4 December 2013 14:15, deco rior <[hidden email]> wrote:
>>>
>>>> You have this
>>>>
>>>> But we need the name of the database to be a variable
>>>>
>>>> What is the syntax for that?
>>>>
>>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso
>>> [hidden email]
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>  the mailing list Lasso
>> [hidden email]
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Datasource (ds) — A modern inline replacement for Lasso 9

Ke Carlton-3
In reply to this post by decorior
Here's an example without using any variables.

define main_ds => ds(::mysqlds,'127.0.0.1',::maindb,'root','')
define customer_ds => main_ds->database(current_customer->databasename)


Regards,

Ke

On 4 December 2013 15:22, deco rior <[hidden email]> wrote:

>
> > But I asure you — you do not need to use variable names for databases.
> You
> > just need to wrap you head around DS a little better...
>
> Ok, but in our application each customer has their own database instance.
> We have ~300 customer using the application with the same code base. When a
> customer logs in their database gets saved as a variable. How else would we
> do this?
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
12