Giter VIP home page Giter VIP logo

Comments (7)

khuezy avatar khuezy commented on June 4, 2024 2

@tywalch I tried using CustomAttributeType per your example but I'm getting this error:

Exported variable 'MyEntity' has or is using name 'OpaquePrimitiveSymbol' from external module "/Users/me/Projects/app/node_modules/electrodb/index" but cannot be named.

Any ideas? Your playground link works fine though.

Typescript version: 4.9.4 (latest)
ElectrodDB version: 2.3.5 (latest)

from electrodb.

ari-becker avatar ari-becker commented on June 4, 2024 1

@ari-becker checking in, we're you able to resolve your typing issue?

Hey, this came up in a side project of mine, no further progress beyond my last comment 🙂

from electrodb.

tywalch avatar tywalch commented on June 4, 2024

For this, I would recommend use of CustomAttributeType to accomplish this -- would that work in your case? I'd imagine given your example it'd be able to accomplish your needs and has the benefit of already being available.

My hesitancy around numeric enums is that Electro can't really enforce what values could end up in the table, when you consider atomic mutations like add and subtract, etc. A formal numeric enum might give users the impression that'd be handled by the library somehow.

from electrodb.

ari-becker avatar ari-becker commented on June 4, 2024

Got it. The following seems (at first glance) to work:

{
  attributes: {
    ratingNumStars: {
      type: CustomAttributeType<0 | 1 | 2 | 3 | 4 | 5>('number'),
      default: 0
    }
  }
}

although, for what it's worth, putting an invalid value in for the default (e.g. 6) doesn't cause a type error.

from electrodb.

tywalch avatar tywalch commented on June 4, 2024

Could it be your version of TypeScript? Here is an example in the playground, which uses the latest version of TypeScript:

https://electrodb.fun/?#code/PQKgBAsg9gJgpgGzARwK5wE4Es4GcA0YuccYGeqCALgUQBYCG5YA7llXWAGbZwB2MXGBDAAUKKwBbAA5QMVMAG8wAUT5V2AT0IBlTADcsAYziEAwqlxUokgIJUq2AEaoqcACqbppAL7cMNmAARIhwRo6wTkEA3OJGUHxWYFQMTgikALzBmlCoGAD6KWlw+XwMknAx4qBg7gy4ANZCahpUmsJi8YkKKY1CWXxwLKrqWgAUomBKk1NgkrCIAFzTs7P8rZrLQb1NQfgzq-qYuFgJWwCMewezxBiGJls7DNLSQdc++6sMDs6ueMuKa5TaQBGCocIASRgAKBsza3i2VmwfAA5ldVlMPrCyhUYRi4V44MsAORIrCo4mwrH4+C4IzYaQaM4rfHJQkkskUqmfDEYb7klF41nwolgCxWGz2RxYFxuTzeAA8AAYwAAfMDnNVgABMWoAzFqACxagCsAD4xsS+KhJE5MMSAJQ81Y+d7OsDk+AAD3+LK+uGIVCF+OkDWDrKmXBwCGhwVD6Ijs3iMigJzcywA2kEQbBwVQoUEALrul0lm5hv2sqOIWOkhrEsurZOyNOijOF2GYqnvGbUpTJVLpMCuh2xUQ7XAAOnpcG+cDGgOBoLzUJJLDnGDtMAAtEqlecGzMcaLiRxSABVahSOdgADqG63h6mtPpWEZpz4JPcdFI8yScC9Rw4AqVgHzgGAwDgI4MDmBh4CfMh+VRZYADZ9h8B1JxRKAxlHIA

from electrodb.

tywalch avatar tywalch commented on June 4, 2024

@ari-becker checking in, we're you able to resolve your typing issue?

from electrodb.

tywalch avatar tywalch commented on June 4, 2024

Thanks for checking back in, if you ever pick things back up be sure to let me know and we can get to the bottom of what you're looking at 👍

from electrodb.

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.