Comments (8)
Looks like there's a problem with seeding the database, which also triggers the creation of design documents (per type) containing the views.
You can try adapting the following seed script https://github.com/michael/substance/blob/master/db/seed.js, it will probably solve your problem.
Updating the schema isn't really covered in the docs yet. Will add this.
from data.
Thank you!
So... I seeded it and the users I had synced disapeared while the views (not previously in the db) appeared. I can now retrieve the user although doing:
graph.fetch({type: '/type/user'}, function(err) {
if (!err) {
var user = graph.get('/user/luis');
console.log(user);
res.send(user.get("name"));
}
});
shows the following in the browser:
{"Luis Gomez":"Luis Gomez"}
Shouldn't it show simply "Luis Gomez"?
This is what's in that user document in couch:
{
"_id": "/user/luis",
"_rev": "1-daf9840f8a91c6c7a170b184752c4a1d",
"name": [
"Luis Gomez"
],
"type": [
"/type/user"
]
}
from data.
Also, I just tried running node seed.js --flush
and my user ("/user/luis") disappeared. Am I missing a step to have it saved correctly?
from data.
Ok, this is weird to me. I see the user being inserted into the database but when I stop and restart the application the user disappears.
Check a more complete copy of the code I'm using. Perhaps I'm just not understanding the documentation:
https://gist.github.com/1078764
If there's anything I can do to help you improve it, feel free to ask. I'm happy to contribute.
Thanks,
from data.
You need to define "name" as a unique property ("unique": true), which means there can be just one value. That's why user.get("name") returns a Data.Hash instead of a unique string value "Luis Gomez".
node seed.js --flush
just resets the whole database. Be careful with that :) If you want to upgrade your schema in a non-destructive way just use node seed.js
. I realize that at some point this seeding thing should go into the lib. ;) For convenience and clarity.
Feel free to add a comment with your addition to the docs where you see it fit. I'll have a look at it and include it.
from data.
Got it. I split that seeding script into two to avoid running it by mistake :)
Thanks a lot for your help. It's working now.
from data.
I'm updating the docs a bit (in preparation of the 0.4.0 release). I also roughly covered the schema evolution thing. http://substance.io/#michael/data-js/_section_164bef6a1497735c9c45020037b6c92c
I decided to leave schema evolution to the user, as it would impose restrictions if I'd include it in the library.
from data.
Nice. Thanks!
I'll try to write a few examples once I finish what I'm working on. Perhaps they'll come in handy for other users.
from data.
Related Issues (20)
- Improved Validation Errors HOT 1
- Watch out for edge cases related to explicitly setting an object type property to null
- Consider adopting JSON-LD syntax HOT 1
- backbone.js models and data.js graphs relation HOT 5
- Syching with couchdb without requiring node.js HOT 1
- Error when assigning a null value to a unique string property.
- unable to export doc at http://substance.io/michael/data-js HOT 1
- On demand value registration (on a property basis)
- Explicit Null values are not stored in the graph
- Supporting map/reduce
- Typo in data.js HOT 2
- Resolve any path HOT 2
- Specify configuration object for type properties in schema HOT 1
- Transactions: operations on a temporary graph clone. HOT 1
- Docs HOT 9
- Indexes on array properties HOT 3
- Consider removing Chronicle dependency
- Website doesn't work HOT 1
- Observing, pub/sub, or other events? HOT 1
- Any place to see how versioning is working?
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 data.