Coder Social home page Coder Social logo

Comments (15)

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

@viczam please take a look here:

http://senecajs.org/tutorials/understanding-data-entities.html

There you can see explanations about using multiple zones for your entities.

Let me know if it is OK by closing this, or add a comment.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

uhm, not really.. I don't want to specify a zone, but a postgresql schema, as a I have my tables nested under a schema.

When parsing the canon, seneca accepts only words for zone / base / name, but you can schema a name like this:

seneca.make({
  entity$: {
    name: `${schema}.${table}`
  }
}).canon$({array: true})

But the table name is escaped later on, so that won't work either.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

is there a way to specify a connection string when setting up the seneca plugin, instead of the existing object?

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

You can specify also default schema for user:

ALTER USER user_name SET search_path to 'schema';

or when using multiple schema:

SET search_path TO myschema,public;

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

You can specify a connection string of the form:

postgres://username:password@localhost/database

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

I think this is a candidate for new feature, specify schema in connect object/url. I will open a feature issue.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

how can I specify the connection string when setting up the plugin?

Probably I wasn't clear enough, but my issue is that I have a lot of tables nested under a schema and I want to make seneca entities for some of those tables and I can't find a way to do that. And that's because when calling saneca.make('SomeEntityThatCorrespondsToATable'), it doesn't know it has to prefix the table with the schema name

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

Yes, for now there is not implemented the feature you need - first I misunderstood what you need. You can use a workaround like the one I described in my previous comment above for now by setting the default schema for connected user. In this case you do not need to use qualified table name.

I created a issue for this feature it will be added on next version.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

A potential fix would be not to escape the table name in query_builder.js, or use a different strategy to allow schema definition as well.
If you do that, you can specify the entity definition this way:

seneca.make$({
  entity$: {
    name: `"${schema}"."${table}"`,
  }
});

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

To match the Seneca store API and not add that "dot naming" that is not standard for us I think the best approach is to specify the schema in the connection object. Then you can use zones/base to select schema as usual for all stores.

I will take a look on that.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

Sounds good, although you might have multiple schemas under the same database and you'll be forced to create different connections to the same database to target each schema in particular.

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

Yes, but this is the way Seneca stores are used to manage
tables/collections from different locations. It allows you to move very
easy schemes to a different database/machine or even different db engine.

malex
Pe 07.01.2016 17:53, "Victor Zamfir" [email protected] a scris:

Sounds good, although you might have multiple schemas under the same
database and you'll be forced to create different connections to the same
database to target each schema in particular.


Reply to this email directly or view it on GitHub
#18 (comment)
.

from seneca-postgres-store.

viczam avatar viczam commented on August 23, 2024

Good point. Then allowing defining schema through the connection sounds like the best solutions.

from seneca-postgres-store.

mirceaalexandru avatar mirceaalexandru commented on August 23, 2024

@viczam I will let you know when this feature is published

from seneca-postgres-store.

brycereynolds avatar brycereynolds commented on August 23, 2024

Did this feature ever ship?

from seneca-postgres-store.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.