Comments (7)
The code for deletion is very simple, so simple that I wouldn't really know where the problem is:
Lines 465 to 487 in 4f82729
Maybe you can confirm that this is the case by adding a find
before you got the ConflictError?
from fortune-postgres.
Also the test for the adapter does create
immediately after delete
: https://github.com/fortunejs/fortune/blob/44e0469e9c81516c96066b9fcea2607900ee0397/test/unit/adapter.js#L584-L585
from fortune-postgres.
Ok, so I add a find before using delete like this
beforeEach(function () {
return store.adapter.find('user').then((res) => {
console.log('RES')
console.log(res)
return database.truncate()
});
});
I get this output
RES
[ count: 0 ]
So there is not user. BUT if I go check in the database, there is one user (added throw fortunejs)
from fortune-postgres.
If I'm switching from
function truncate() {
return store.adapter.delete('user')
.then(() => store.adapter.delete('customer'));
}
to
function truncate() {
return store.adapter.delete('customer')
.then(() => store.adapter.delete('user'));
}
I not longer have the error, but I don't know why
from fortune-postgres.
Hmm, I'm not sure where the problem is, since the tests for this adapter seem to do what you're trying to do without error.
Basically this should work:
return adapter.delete(type)
.then(() => adapter.create(type, records))
If that doesn't work then it would be a problem here.
from fortune-postgres.
Ok I found why :
- I was mixing
store.XYZ
andstore.adapter.XYZ
- When you create a record using
store.adapter.create(type, records)
, records MUST be an array. Otherwise it will only callreturn new Promise().resolve()
- When adding data using
store.adapter.create
you have to manually insert relationship both in each parts. So in my case I had to put the customer id inuser.customer
and push the user id in thecustomer.users
from fortune-postgres.
Yup, Fortune.js handles relationships but the adapter doesn't.
from fortune-postgres.
Related Issues (20)
- perent id error HOT 7
- A new column cannot have a not-null constraint HOT 3
- Number primaryKeyType not using numbers HOT 3
- Client pooling HOT 6
- Any plans for join tables for many-to-many? HOT 2
- Complete n00b question -- apologies HOT 3
- Auto-generated IDs can sometimes have backslash in them HOT 4
- Sharing DB connections with the rest of the app HOT 2
- node-postgres usage is "soft-deprecated"
- TODOs
- Error when no database named "postgres" exists HOT 7
- Deadlock when connection pool is exhausted
- fortune-postgres 1.6.9 is not compatible with node 8.x LTS HOT 1
- Query to information_schema.columns selects columns from all schemas HOT 3
- How to specify the primary key of a type? HOT 3
- Connection terminated due to connection timeout
- Hasmany relation creates __source_targets_inverse column: why? HOT 1
- Implement `range` and `exists` HOT 1
- Implement transactions HOT 1
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 fortune-postgres.