Giter Club home page Giter Club logo

Comments (16)

crandmck avatar crandmck commented on June 14, 2024 1

I added this: https://docs.strongloop.com/display/APIC/Model+definition+JSON+file#ModeldefinitionJSONfile-MySQLindexes

Please let me know if I need to add anything more (or change anything).

from loopback-connector-mysql.

wrensburg avatar wrensburg commented on June 14, 2024

Found so many bugs with indexes and mysql. For this specific use case, I found a work around (not documented). Convert yourindexes property above to use columns, rather than keys, like this..

"indexes": {
    "fripId_tagId_index": {
      "columns": "fripId, tagId"
    }
  }

from loopback-connector-mysql.

saystone avatar saystone commented on June 14, 2024

@wrensburg it works. thanks!

from loopback-connector-mysql.

sgilligan avatar sgilligan commented on June 14, 2024

+1

For mysql I'm using:

"indexes":
{
    "UNIQUE_REGISTRATION":  {
        "columns": "siteId,userId",
        "kind": "unique"
    }
},

works per this code: https://github.com/strongloop/loopback-connector-mysql/blob/master/lib/migration.js#L222-L243

from loopback-connector-mysql.

superkhau avatar superkhau commented on June 14, 2024

@saystone Has this been resolved? Can I close this?

from loopback-connector-mysql.

saystone avatar saystone commented on June 14, 2024

@superkhau Sorry for the late response. It was resolved. Btw I can't find strongloop documentation for create indexes on MySQL. Where can I find it? (https://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Indexes -> still different implemented loopback-connector-mysql code)

from loopback-connector-mysql.

superkhau avatar superkhau commented on June 14, 2024

@saystone No problem. I'm not sure where it's in the docs, but @crandmck would know.

@crandmck ^

from loopback-connector-mysql.

crandmck avatar crandmck commented on June 14, 2024

I don't think we have anything specific for creating MySQL indexes. This is for "auto-migration", right?
We have docs for that: https://docs.strongloop.com/display/LB/Creating+a+database+schema+from+models but nothing specific to MySQL.

Let me know if we need to add something.

from loopback-connector-mysql.

snowyu avatar snowyu commented on June 14, 2024

the keys in the strongloop documentation has still not worked on the mysql connector.

from loopback-connector-mysql.

crandmck avatar crandmck commented on June 14, 2024

The comment above says:

It was resolved.

Which I thought meant that keys now worked on MySQL. Is that not the case?

from loopback-connector-mysql.

snowyu avatar snowyu commented on June 14, 2024

No, It DOEST NOT work yet. The only way is a workaround: use the columns instead.

from loopback-connector-mysql.

lotas avatar lotas commented on June 14, 2024

+1
Official Model definition JSON mention nowhere that there is a "columns" property for "indexes": {} definition, which is confusing, at least.

Manually writing "columns" works, but is there anywhere documentation for this?

from loopback-connector-mysql.

snowyu avatar snowyu commented on June 14, 2024

and should tell people: the keys does not work for mysql in the current version.

from loopback-connector-mysql.

saystone avatar saystone commented on June 14, 2024

Oh... Sorry for my miss communication.
I said 'It was resolved'. But I mean it's not for document. It means @wrensburg's solution.
Ultimately, The document was fixed correctly by @crandmck. But I think some additional comment for document. How can I contribute document?

from loopback-connector-mysql.

crandmck avatar crandmck commented on June 14, 2024

How can I contribute document?

@saystone Currently, the best way to contribute is to just suggest changes/additions in a GH issue (i.e. here) and I will make the change. We're working on getting the docs into a GH repo, but that's going to take quite a bit of time & work :-)

from loopback-connector-mysql.

buokae avatar buokae commented on June 14, 2024

I cannot get this to work. I defined

    "indexes": {
      "RANDOM_UNIQUE_INDEX": {
        "columns": "account,order,filename",
        "kind": "unique"
      }
    },

in my model and on autoupdate I get an error:
ErrorError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,filename)' at line 1

MySQL 5.7.19, "loopback-connector-mysql": "^5.2.0"

EDIT: fixed it by changing the colums line, notice the strange use of backward leaning quotes:

"columns": "`account`,`order`,`filename`",

Works though, I'll try and update the docs.
EDIT2: loopbackio/loopback.io#539

from loopback-connector-mysql.

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.