Giter Site home page Giter Site logo

Comments (8)

michael avatar michael commented on May 30, 2024

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.

lgomez avatar lgomez commented on May 30, 2024

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.

lgomez avatar lgomez commented on May 30, 2024

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.

lgomez avatar lgomez commented on May 30, 2024

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.

michael avatar michael commented on May 30, 2024

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.

lgomez avatar lgomez commented on May 30, 2024

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.

michael avatar michael commented on May 30, 2024

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.

lgomez avatar lgomez commented on May 30, 2024

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)

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.