Comments (8)
LoopBack assumes that there is always a PK. It's required for a lot of APIs to be functional. Is there a reason that your table cannot have a PK?
You can also fake a PK by adding id: true
to one of your property definitions.
from loopback-connector-oracle.
I'm working on an existing database that doesn't have PK for some reasons and that I can't modify. There are some unique constraints that I could use as PK, but there is nothing related to unique constraint in model.definition.properties[propertyName]
. Is there a way to know in the generated model where the field with unique constraint is?
Thanks.
from loopback-connector-oracle.
Do you use discovery to build loopback models from oracle tables?
You can always nominate a property as an id (pk) in loopback by setting id to true. It doesn't require a DB PK.
Sent from my iPhone 5
On Jul 16, 2014, at 1:02 AM, vbourgeois [email protected] wrote:
I'm working on an existing database that doesn't have PK for some reasons and that I can't modify. There are some unique constraints that I could use as PK, but there is nothing related to unique constraint in model.definition.properties[propertyName]. Is there a way to know in the generated model where the field with unique constraint is?
Thanks.
—
Reply to this email directly or view it on GitHub.
from loopback-connector-oracle.
Yes I use the "discoverAndBuildModels" method, but it doesn't seem to get the unique constraints I want to use as PK. Does it matter if I select a random property as PK or it will add constraints on it in loopback?
from loopback-connector-oracle.
I finally found a way to identify the eligible column for primary key.
Model is built with discoverAndBuildModels
and I tried to set the PK manually like this: model.definition.properties[idName].id = true;
.
But it's not working, dataSource.idName(modelName);
still returns undefined
and causes the create method to fail.
How can I set the PK manually?
from loopback-connector-oracle.
Can you do the following?
model.definition.rawProperties[idName].id = true;
model.definition.build(true); // Force rebuild the list of properties
from loopback-connector-oracle.
It's working, PK is set and create method works.
Thank you.
from loopback-connector-oracle.
I am working with a mongo db collection called users with the following fields : _id (default mongo created pk field), email, username, status.
I have created a model where I have marked email field as the id field. But after going through the full cycle when i run the get query for /users/{id} loopback queries only the _id field but doesnt query the email field (which I have marked as the id field in my model). Can someone help me in changing this?
Thanks
from loopback-connector-oracle.
Related Issues (20)
- How can make a request insensitive HOT 6
- Loopback oracle connector issues HOT 16
- Fix CI HOT 1
- Loopback 4 oracle connector is not working HOT 9
- INSERT / RETURNING fails due to upper-cased id column name. HOT 2
- New release with 3.x driver? HOT 3
- Insert into BLOB field fails HOT 3
- Feature request: Add support for connection URL HOT 4
- Oracle DB security support HOT 3
- Connector version for Loopback 2 HOT 2
- Loopback 3 error "errornum": 942, "offset": 92, HOT 2
- Run shared tests from both v3 and v4 of juggler
- Fix CI Failures HOT 3
- node-oracledb 4.0 is avaialble HOT 2
- Make local tests pass HOT 2
- New release with 4.0 driver? HOT 2
- oracledb dependency HOT 6
- NodeJS-Oracle DB - NJS-040 Connection Timeout using oracle driver with Lopback with in the ICP (loopback-connector-oracle) HOT 2
- Support for node-oracledb 5.1 HOT 4
- Node.js application not working with Oracle 19C RAC database HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loopback-connector-oracle.