How does the link in the database.js works?

24 views
Skip to first unread message

saywow

unread,
Nov 6, 2013, 6:22:11 PM11/6/13
to part...@googlegroups.com
Hello: I am trying to find information on the database.js  .
From inspecting the sample database.js the link follows the similar naming convention as the title except  it is all lower case and all spaces are replaced by -.  Is this a requirement?
How does it work?
I played around by modifying the title and then link but them ran into some error -undefined:3
 Syntax Error: unexpected identifier

If I just modify the title and not the link, the navigation works but http://xxx.xxx.xxxx.com:8005/how-to-create-a-website/
you can see that  it still uses the how-to-create-a-website

but I really want it to be
http://xxx.xxx.xxxx.com:8005my-own-topics/

Thanks again

saywow

unread,
Nov 6, 2013, 6:30:02 PM11/6/13
to part...@googlegroups.com


I figured out it and now I can do
 http://xxx.xxx.xxxx.com:8005my-own-topics/

Thank you.

Peter Širka

unread,
Nov 7, 2013, 1:13:27 AM11/7/13
to
Hi saywow,
database.js does not exist in the framework (framework supports NoSQL embedded database - https://github.com/petersirka/nosql). Attach source code here please.

Thanks!

Hasan A Yousef

unread,
Nov 7, 2013, 7:05:23 AM11/7/13
to part...@googlegroups.com
awaiting for the todo list example using the NoSQL, with some documentation/guidlines/hints.

Peter Širka

unread,
Nov 7, 2013, 7:08:56 AM11/7/13
to part...@googlegroups.com
I'll write simple todo app during this weekend.
Thanks.

saywow

unread,
Nov 7, 2013, 9:56:54 AM11/7/13
to part...@googlegroups.com
Awesome, thanks so much. I am a new learner to the framework, so please bear with me if I have silly questions :-) but documentation is
always the starting point .

Peter Širka

unread,
Nov 9, 2013, 11:58:05 AM11/9/13
to part...@googlegroups.com
Hi guys,
I prepared example of TODO list written in partial.js.

Optimized for Google Chrome, Safari, Firefox and Opera:

The problem:
I'm simple working with NoSQL embedded database, sorry :-(

In attachment is the source code.
Many thanks.
todoapp.zip
Message has been deleted

Hasan A Yousef

unread,
Nov 9, 2013, 12:10:12 PM11/9/13
to part...@googlegroups.com
Peter,
It looks something wrong in the zipped filed, can not be extracted, as attached,
err.png

Hasan A Yousef

unread,
Nov 9, 2013, 12:17:18 PM11/9/13
to part...@googlegroups.com
Peter..
Can you pls add an "update" option, so we learn how to use this function by example.

Thnx

Peter Širka

unread,
Nov 9, 2013, 12:28:45 PM11/9/13
to part...@googlegroups.com
Hasan try download now.
I haven't Windows but I compressed this example with other application.

Thanks!

Peter Širka

unread,
Nov 9, 2013, 12:40:01 PM11/9/13
to part...@googlegroups.com
Simple example:

var db = framework.database('some-database');

// EXAMPLE:

db
.insert({ id: 101, count: 0 });
db
.insert({ id: 150, count: 0 });
db
.insert({ id: 151, count: 0, isDeleted: true });
db
.insert({ id: 300, count: 0 });

// UPDATE
// this function reads each document in database and replaces it according returning value
db
.update(function(doc) {
 
   
// current document will be removed from DB if return null or return undefined
   
if (doc.isDeleted)
       
return;


    if (doc.id > 100 && doc.id < 200)
        doc
.count++;


   
if (doc.id === 300)
        doc
.name = 'PETER';


   
// current document will be replaced according returning document
   
return doc;
});


// OUTPUT:
// { id: 101, count: 1 }
// { id: 150, count: 1 }
// { id: 300, count: 0, name: 'PETER' }

Thanks!

Hasan A Yousef

unread,
Nov 10, 2013, 12:18:54 AM11/10/13
to part...@googlegroups.com
Thanks Peter, got it downloaded, and it is working, I've to dive in it now, thanks alot.

Hasan A Yousef

unread,
Jan 1, 2014, 1:52:15 AM1/1/14
to part...@googlegroups.com
Hi Peter.. and happy 2014 for you and for Partialjs.

How to check the latest "id" in the no SQL?

Assuming I want to add a user to the database, and want the system to generate id based on thelatest one,like AUTO INCREMENT in SQL databases, how can this be done.

Regards,
Hasan

Peter Širka

unread,
Jan 1, 2014, 3:43:09 AM1/1/14
to part...@googlegroups.com
Hi Hasan,
thanks!
  • NoSQL doens't support AUTO_INCREMENT
  • For latest ID use a timestamp, example:
  • Or use GUID generator, example:

console.log(new Date().getTime());

// or use partial.js GUID generator

console
.log(utils.GUID(10));
How to check latest id in NoSQL embedded database?
It's easy :-)

var id = 0;

var lastest = function(doc) {
   
if (doc.id > id)
       
id = doc.id;
};

nosql
.each(latest, function() {
    console
.log('Latest id: ', id);
});


Message has been deleted

Hasan A Yousef

unread,
Jan 1, 2014, 8:24:31 AM1/1/14
to part...@googlegroups.com
Thanks Peter...
It looks the last line in the noSQL is not readable! kindly look into the attached, 
err.png

Peter Širka

unread,
Jan 1, 2014, 8:28:27 AM1/1/14
to part...@googlegroups.com
:-) yes because you're add manually a new data into the database.
At last line you must add NEWLINE (\n) character :-)

EDIT database and enter ENTER at end of last line.

Hasan A Yousef

unread,
Jan 1, 2014, 8:52:58 AM1/1/14
to part...@googlegroups.com
:) yes,
it is fine now.
THANKS

Hasan Yousef

unread,
Jan 5, 2014, 4:31:35 PM1/5/14
to part...@googlegroups.com
Hi Peter..

I just made a copy/paste of the logon function with authorization from my "step-by-step" testing app, to another app, and got the attached error,,, some thing about "one" in db!

is there something else I need to do, other than just copying this function,, I looked to see if you made some definition in the controllers and others, but could not find!

Regards,
Hasan


snapshot1.png

Peter Širka

unread,
Jan 6, 2014, 3:49:00 PM1/6/14
to part...@googlegroups.com
Hi Hasan,
send me your all definitions, thanks.

Hasan Yousef

unread,
Jan 6, 2014, 4:00:44 PM1/6/14
to Peter Širka, part...@googlegroups.com
Hi Peter...
Attached the full app as of now.. including the modified authorization.js I made, pls look into it, and comment... pls I need you help to fix the last 2 lines, instead of showing a plain test, I need to load html page, but could not manage it, as everytime system will ask to load it from different route (depeneds on the accessed unauthorized linked(:

self.plain('YOU DO NOT HAVE A PERMISSION.')
          //  self.view('~unauthorized');

Thanks, and good night, it is 00:00 here :)


On Mon, Jan 6, 2014 at 11:49 PM, Peter Širka <peter...@gmail.com> wrote:
Hi Hasan,
send me your all definitions, thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "partial.js - web application framework for node.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/partialjs/IDz4cvTQ4Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to partialjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

FreshApp.zip
Reply all
Reply to author
Forward
0 new messages